Closed ozra closed 7 years ago
I've only been coding LS for a while, on and off, never run into this before, but now that it's brought up, I'd say this is a proper bug.
you mean variable names in code?
Haha, yes.
a-foo-1 = 47
a-foo-2 = 42
a-foo = 49
a-foo-1 is a-foo - 2
You may use alphabet, to follow this style, for example:
a-foo-a = 47 a-foo-b = 42 a-foo = 49 a-foo-a is a-foo - 2
Personally, I use a similar approach,
a = 1 b = 2 c = 3 a == c - 2
For that matter, a-foo1
, a-foo2
, etc. are also valid identifiers.
I'm of the opinion that this would be too potentially disruptive a change for too little a benefit for LiveScript's current stage of maturity. Seems like a decent thing for any LiveScript successor languages to consider, though.
Docs say:
Lisp hackers, you may be pleased to know that you can use dashes in the name of your variables and functions.
In LISP, you can do this:
(define foo-2-bar 12)
In LiveScript you cannot. Therefore, my conclusion is that this is a bug. I don't know why fixing this bug would be disruptive, though. In a language that allows hyphens in variable names, I'd like to believe nobody would even think of writing foo-12
to mean foo - 12
.
I regret to inform you that, despite what you'd like to believe, the LiveScript source itself has over 30 occurrences of i-1
, op.length-2
, etc. Do you have any reason to believe that the general population of LiveScript programmers is universally more strict in this regard?
Do you have any reason to believe that the general population of LiveScript programmers is universally more strict in this regard?
I no longer do. If LiveScript code base itself has such ambiguities, I guess there is no other way than to live with it.
This was done on purpose to allow for existing uses where the subtraction operator was used without spaces. This is especially prevalent in array indices, eg. arr[i-1]
@determin1st - yeah, I know :) But I want foo-1-mongoose-2
, but... I've survived so far without it. Worse is all languages that don't accept dashes at all :)
@rhendric - seems LiveScripters are less prudent than the typed-langs populace then (that was the majority of code I analyzed to be honest). My "assumption" on the LS-crowd was rather tongue in cheek though, but the facts are welcome ;-). Non-typed-lang users usually code more "hacky" in my experience — so it's not entirely surprising (I code more "hacky" in LS than in C++, Onyx, Crystal... so it's not to throw blame or anything)
@gkz - yeah, it's obvious that it's purposefully designed that way, I didn't think it was an error vis a vis specs - I just believe that allowing it would be more useful than non-spaced subtraction :)
Well, I think we can definitely conclude (based on @rhendric's research) that this is a definite no go, I'll close this.
I've been coding LS for yeeears, and finally I think I should issue a complainty complaint... feature wish...
So after that ado:
for 0 to len-1
(pseudo syntax to cover for x langs) was the construct where hyphen was ever used non-spaced. Somewhat good form, is pretty common that is.foo-bar-3
andfoo-bar-4
etc.Thoughts?