Skip to content
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

own? #1019

Closed
rampall opened this issue Jan 6, 2011 · 7 comments
Closed

own? #1019

rampall opened this issue Jan 6, 2011 · 7 comments

Comments

@rampall
Copy link

rampall commented Jan 6, 2011

is own a keyword?

i don't see it mentioned (COFFEE_KEYWORDS) except in the documentation example:
for own key, value of object

@hen-x
Copy link

hen-x commented Jan 6, 2011

It's a contextual keyword, so it only has special meaning when it follows for and precedes another identifier. You can still use it as an identifier; you can even legally write for own own of own if you want to be confusing.

@rampall
Copy link
Author

rampall commented Jan 6, 2011

Ah thanks!

P.S for own own of own has quite a zen feel to it - i must admit

@dvv dvv reopened this Apr 27, 2011
@dvv
Copy link

dvv commented Apr 27, 2011

Please, consider the following: if own prop of obj then ... which could compile to if (Object.prototype.hasOwnProperty.call(obj, prop)) {...} and would literate-ize quite a common pattern, imho.
TIA,
--Vladimir

@michaelficarra
Copy link
Collaborator

@dvv: own = (prop, obj) -> Object::hasOwnProperty.call obj, prop allows you to do if own prop, obj then .... Not a perfect solution, but it's probably good enough. There was a previous suggestion for this, let me look it up. Can't find it, oh well.

@dvv
Copy link

dvv commented Apr 27, 2011

sure. That is what i do so far in hope own will become truly helpful keyword. The reasons: each and every file must contain this purely routine shim; one may accidently overwrite 'own' implementation; chances are that compiler already included hasOwn helper which is then purely a bloat; braces required in case of complex objects.

@jashkenas
Copy link
Owner

I'm afraid this shouldn't be a keyword -- it's already a method on every object. We don't need to turn Object.prototype methods into keywords just for convenience.

@dvv
Copy link

dvv commented Apr 28, 2011

What if rename implicit __hasProp to own and always bundle it, so that the coffee code look clean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants