Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Smalltalk-like cascading #72

Closed
redalastor opened this Issue · 8 comments

5 participants

@redalastor

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

@satyr
Owner

Things to consider:

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

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
Owner

Related discussion ongoing at: jashkenas/coffeescript#1495

@satyr
Owner

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

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

looks cool, but not really clear

@satyr
Owner

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();
@quarterto

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
Owner

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 josher19 referenced this issue from a commit in josher19/LiveScript
@gkz gkz optimize concat - closes #72 718a547
@quarterto quarterto referenced this issue in gkz/LiveScript
Closed

With-pipe #121

@satyr satyr closed this in f921b24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.