-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: property setting shorthand #63
Comments
While we're at it, how about the LiveScript flag syntax as well?
|
Now you used the newly proposed Tup syntax, not Map (aka Hash) syntax, however, I assume you meant Incidentally this will only be possible if I implement the new Tup(le) literal syntax (that you used in the example). The reasons for going with the new Tuple syntax are piling up, so I'll put the macro-work to the side and implement that next thing (probably today). Then these will be possible. I like it:
Also supporting Tag-keys ("symbols") is a good idea too! Now, what stands against it is
Regarding the flag "lookup hash" sugar - I like that too - though the obvious construct to use for that is a Set in many cases (albeit then you'd only have "it is in the set" or "it's not in the set"). Collisions with the intended Set-literal-notation:
And that means we just have to think a bit more, because I really like the suggestions. I'll make an example using Set, Map and Tup to get a bit of overview here:
I think the "identifier in the key-pos", aka colon is suffixed, and value left out, looks better - less confusion for Crystaleers and Rubyists also. Some words about
|
Silly me.
Technically you're talking about a HashSet, then. A true Set would only be If we're talking about a HashSet, we could add So you want
Never use an apostrophe to denote a plural. Not only is it wrong, but I also find it horribly annoying ;) |
No syntax decisions should be derived from the implementation detail in this case. Map is used for most Sets to store inclusion, a specific implementation will be used for intish Sets, but in all cases: it's really an opaque implementation detail, and should be expected to change at any time. A Set either contains a value or not, that's all "on the surface". Regarding +/-, it would be good for the flag-hash, but not for removing items from a set. It should mean set key x to true|false and not "remove item with key x" / "remove value x from set" - different things, and subtly so in some use-cases which makes it even more dangerous. Yes, either colon before or after seems good choices, they denote the key-relation, which is non-existent in Sets, thereby clearly separating them visually and syntactically. Shuffling the notation and writing a few examples with a little context will give us a clearer picture of which choices to make regarding the details here.
Ah, stupid mistakes like that crawl in when I get tired, thanks for the poke! (common mistake for us Swedes: suffix 's' always indicate possessive in Swedish, plural has (multiple) other endings) |
I did suggest |
My bad - totally missed that. I'll re-read and re-consider for further discussion before nailing and implementing. |
May use
x
in place ofx: x
in a hash, when the key name is the same as the variable name, a la LiveScript:FWIW, I often find myself doing stuff like
{url: url, img: img, web_content: web_content}
in Ruby, so this could be useful.Should probably support symbol keys:
The text was updated successfully, but these errors were encountered: