kal
kal copied to clipboard
Add the property/value of keywords to for loops
Right now it just supports comprehensions
Should it be better to go reversely, make object comprehension consistent with the loop syntax?
The current syntax of object comprehension is quite verbose, and it makes the word value
and property
unavailable to the user.
I know Kal is designed to be expressive and readable, but in this case, both word are very common to be used naming variables in other languages. Using simple and proper variable names should be important to readability.
I think it won't hurt for some prepositions or conjunctions to be reserved, but nouns are different stories.
Maybe something like the following would be better?
[v for v in obj]
[obj[k] for k of obj]
["#{k}:#{v}" for k with v of obj]
I agree that property
and value
should not be reserved (plenty of valid use cases for these as variables). I don't think this necessarily requires a change to the comprehension syntax, though.
I'll definitely keep this on the map to remove the restriction on property
and value
.