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

Smalltalk-like cascading #72

Closed
redalastor opened this issue Jul 21, 2011 · 8 comments
Closed

Smalltalk-like cascading #72

redalastor opened this issue Jul 21, 2011 · 8 comments
Milestone

Comments

@redalastor
Copy link

I'd like to suggest smalltalk-like cascading which I already suggested for CoffeeScript: jashkenas/coffeescript#1431 (comment)

@satyr
Copy link
Owner

satyr commented Jul 22, 2011

Things to consider:

  • The right syntax.
  • Interaction with ?. .= etc.
  • Is our with insufficient enough to require this?

@mcfog
Copy link

mcfog commented Dec 24, 2011

I think the syntax might be sth similar to .~

a.~b => __bind(a,a.b)
a.!b => __chain(a,a.b)
where we have

function __chain(me, func) {
    return function() {
        func.apply(this/*or `me` thinking about whether chained method must be bound?*/, arguments);
        return me
    }
}

@satyr
Copy link
Owner

satyr commented Jun 29, 2012

Related discussion ongoing at: jashkenas/coffeescript#1495

@satyr
Copy link
Owner

satyr commented Jul 22, 2012

"Expression Block" is unambiguous on top-level. Making this a with alias gives:

document.querySelector '#eyecatch'
  @style
    @color    = \red
    @fontSize = \large
  @scrollIntoView!

@vendethiel
Copy link
Contributor

looks cool, but not really clear

@satyr
Copy link
Owner

satyr commented Jul 23, 2012

with semantics may seem too implicit and/or cumbersome due to the context/scope change.

Instead introducing another symbol for simple substitution for the cascade target would give:

document.querySelector '#eyecatch'
  &style
    &color    = \red
    &fontSize = \large
  &scrollIntoView!

var x$, y$;
x$ = document.querySelector('#eyecatch');
y$ = x$.style;
y$.color = 'red';
y$.fontSize = 'large';
x$.scrollIntoView();

@apaleslimghost
Copy link

Not that this should make a difference, but remember LiveScript are using & for their arguments shorthand. Does anyone actually use labels? Can't we pick something else for the label syntax and just use : here?

@satyr
Copy link
Owner

satyr commented Jul 23, 2012

LiveScript are using & for their arguments shorthand.

So what?

Can't we pick something else for the label syntax and just use : here?

Colon makes most sense for labels.

Does anyone actually use labels?

Probably more relevant as named destructuring/let.

josher19 pushed a commit to josher19/LiveScript that referenced this issue Jul 24, 2012
@satyr satyr closed this as completed in f921b24 Jul 26, 2012
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

5 participants