Author Topic: Hyphen in function/subroutine/variable names  (Read 3568 times)

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
I'd like to request that "-" could be used in function, subroutine and variable names. I know you can use the "_" (underscore) character, but hyphen would also be useful.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1772
    • View Profile
    • Homepage
Re: Hyphen in function/subroutine/variable names
« Reply #1 on: 2009-May-28 »
That could be confused with subtraction, not sure that would be usefull :-)

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
Re: Hyphen in function/subroutine/variable names
« Reply #2 on: 2009-May-28 »
Hmmmm... That's a good point - hadn't thought of that. Might be best to stick with underscores then.

Online Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
Re: Hyphen in function/subroutine/variable names
« Reply #3 on: 2009-May-28 »
No language use "-" on functions/variables...
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline S. P. Gardebiter

  • Mr. Polyvector
  • ***
  • Posts: 245
    • View Profile
    • Tile 44 Interactive
Re: Hyphen in function/subroutine/variable names
« Reply #4 on: 2009-Jun-03 »
No language use "-" on functions/variables...


Bad knockoff argument.
Does that mean that GLBasic doesn't need to support it? No.
~ Cave Story rules! ~

Online Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
Re: Hyphen in function/subroutine/variable names
« Reply #5 on: 2009-Jun-03 »
Thats the best argument at all!
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
Re: Hyphen in function/subroutine/variable names
« Reply #6 on: 2009-Jun-04 »
don't waste development resources on these details - there's so much more that has wider utility

While I have things I would personally prefer to see implemented before this, I think you are overlooking a few things with your comment
1) Development resources aren't "wasted" if the feature is something people want
2) Whether something like "serial communication" has wider use or not is purely a matter of opinion - I personally have no use for it but would get a lot of use out of hyphens in function names
3) This may be a very quick thing to implement so it might make sense for Gernot to add this in before some of the other features.

Telling Gernot not to "waste" resources on something other people want suggests that your requests are more important and I think that is for Gernot to decide. Maybe saying something like "I would prefer to see you develop ..." or "I wouldn't find this of any benefit" might be a better way to put it perhaps?

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1772
    • View Profile
    • Homepage
Re: Hyphen in function/subroutine/variable names
« Reply #7 on: 2009-Jun-04 »
My comment still stands. This would break most programs already written that uses subtraction in any way next to a variable.

For example this would suddenly get you a for-next-loop that runs ONCE, not to the length of your array:
Code: GLBasic [Select]
FOR n = 0 to length-1
    DRAWSPRITE array[n], 50, 50
NEXT
 
This might add lots for you but it would break almost all my programs and I actually already use them for work and don't want to spend time rewriting them.

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
Re: Hyphen in function/subroutine/variable names
« Reply #8 on: 2009-Jun-04 »
All,
Before we have a full scale argument about this about this, you'll note that I actually agreed it's probably best left so that you can't use hyphens.  =D
 
Hmmmm... That's a good point - hadn't thought of that. Might be best to stick with underscores then.
Yes it could cause ambiguity depending on how you used it, but so can other things that you already can do in the language - like writing "value=1+2*3" for example. It's not ambiguous to the compiler, it knows how to process that, it's ambiguous to the person reading it (ie. is it "(1+2)*3" or "1+(2*3)").

I actually have written a compiler (lexical analyser/parser etc) before though admittedly it was a few years back - so I do know how they work. When coding them your tokeniser has an order of precedence (just like the compiler for mathematical operators). In the same way that the compiler is configured to process mathematical problems in the right order (ie it works out that 1+2*3 = 7 rather than 9), the tokeniser follows a ruleset to determine what are function/variable names and what are calculations. It is then a programmers job to make sure they don't write their program such that the outcome is ambiguous - in the same way that a good programmer would write "value=1+(2*3)" rather than "value=1+2*3"
Whether the tokeniser/parser changes would be easy to do from Gernots point of view is purely a question of how he has coded GLBasic - the problem can actually be rather straightforward from a coding point of view depending on how the backend is written.
And I'm all for expanding the language - this request (and the others I've posted) would never have been written if I wasn't. Like hopefully everyone else, I just want to see a bigger and better language. It's amazing what Gernot can accomplish as a one man team!

Online Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
Re: Hyphen in function/subroutine/variable names
« Reply #9 on: 2009-Jun-04 »
But Gernot never do that ;)

It look horrible "my-cool-function()" wtf...
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard