Hyphen in function/subroutine/variable names

Previous topic - Next topic

FutureCow

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.

Moru

That could be confused with subtraction, not sure that would be usefull :-)

FutureCow

Hmmmm... That's a good point - hadn't thought of that. Might be best to stick with underscores then.

Schranz0r

No language use "-" on functions/variables...
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

S. P. Gardebiter

Quote from: Schranz0r on 2009-May-28
No language use "-" on functions/variables...


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

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

FutureCow

Quote from: Ocean 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?

Moru

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.

FutureCow

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
Quote from: FutureCow on 2009-May-28
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!

Schranz0r

But Gernot never do that ;)

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

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard