kal icon indicating copy to clipboard operation
kal copied to clipboard

Add the property/value of keywords to for loops

Open rzimmerman opened this issue 12 years ago • 2 comments

Right now it just supports comprehensions

rzimmerman avatar Jan 22 '13 22:01 rzimmerman

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]

yydonny avatar Oct 23 '13 03:10 yydonny

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.

rzimmerman avatar Oct 24 '13 05:10 rzimmerman