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

prototype shorthand (A::) sticks to 'then' and 'when' #1477

Closed
dbrans opened this issue Jun 29, 2011 · 8 comments
Closed

prototype shorthand (A::) sticks to 'then' and 'when' #1477

dbrans opened this issue Jun 29, 2011 · 8 comments

Comments

@dbrans
Copy link

dbrans commented Jun 29, 2011

for k of A:: when k isnt constructor then 

compiles to

var k;
for (k in A.prototype.when(k !== constructor)) {}

and

if A:: then 2

produces a parse error

@satyr
Copy link
Collaborator

satyr commented Jun 29, 2011

Usability aside, this is because you can access a property using any identifier, including reserved ones.

$ coffee -bpe 'A :: when'
A.prototype.when;

$ coffee -bpe 'A . prototype . when'
A.prototype.when;

@ghost
Copy link

ghost commented Jul 19, 2011

for k of (A::) when k isnt constructor then 

@michaelficarra
Copy link
Collaborator

We could require the :: operator to be pushed up against its operands. It's not like anyone intentionally puts whitespace there anyway, do they?

@jashkenas
Copy link
Owner

For the record, the :: was never intended to be used without a right-hand connection. It's like writing object. standalone. Hence the syntax error.

@ghost
Copy link

ghost commented Jul 19, 2011

@jaskenas

What about doing things like
Object.defineProperty A:: ...stuff...

@jashkenas
Copy link
Owner

Object.defineProperty A.prototype

... honestly, it might be worth getting rid of standalone @ while we're at it.

@TrevorBurnham
Copy link
Collaborator

I think people have grown attached to standalone @. The style I use in the book is to use standalone this instead (and @x), but I wonder if that may have been the wrong decision. After all, it makes perfect sense to highlight the specialness of this, that oh-so-common source of bugs. @ really pops out. In fact, I think I'd rather get rid of standalone this than standalone @. (Not a serious suggestion; obviously the same reasoning applies to this as to && and ||).

I'm indifferent to A::.

@GeoffreyBooth
Copy link
Collaborator

Not sure what the issue is here. if A:: then 2 should produce a parse error.

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

No branches or pull requests

6 participants