Giter VIP home page Giter VIP logo

Comments (5)

vendethiel avatar vendethiel commented on September 8, 2024 2

I'd say CoffeeScript is not consistent with itself here: the only call introducers are supposed to be whitespace and (.

Coco and LiveScript did change this (a?b is a?.b), though I'm not 100% sure it was meant to change the meaning of a?b then (Coco 0.4.2: "Enabled ADI on ?.", but the commit adds a test without removing or changing another one)

from civet.

edemaine avatar edemaine commented on September 8, 2024

Oddly, CoffeeScript treats @?trigger "changed" like @? trigger "changed", i.e., as two function calls. This is pretty weird though.

This is related to a question I asked a while back on Discord: should x?y be shorthand for x?.y, just like how x?(y) is shorthand for x?.(y) and x?[y] is shorthand for x?.[y]? I think making @?x shorthand for this?.x is less controversial, though, because @x is already shorthand for this.x which includes the dot.

from civet.

vendethiel avatar vendethiel commented on September 8, 2024

Oddly, CoffeeScript treats @?trigger "changed" like @? trigger "changed", i.e., as two function calls. This is pretty weird though.

It's self-consistent - the parens are invisible, not the dot.
@?foo is this && this(foo) in CoffeeScript, not this && this.foo() (just like a?b is a && a(b), not a && a.b). Coffee considers @ to be callable (which, well, is fair enough.)

from civet.

STRd6 avatar STRd6 commented on September 8, 2024

Hmm, we may want to go for consistency with CoffeeScript then, or at least note it and have a compat flag.

from civet.

edemaine avatar edemaine commented on September 8, 2024

TIL CoffeeScript treats f?g like f? g also. So I agree it's somewhat consistent on this point, but it doesn't match my own intuitive definition of implicit calls which would have matched @vendethiel's:

the only call introducers are supposed to be whitespace and (.

However, CoffeeScript's actual definition is vague:

You don’t need to use parentheses to invoke a function if you’re passing arguments. The implicit call wraps forward to the end of the line or block expression.

I don't see any CoffeeScript tests about this, nor could I find an issue.

But when we define a meaning for @?foo and/or foo?bar, I agree we should probably add a coffeeCompat flag, even though I couldn't find any real-world usage.

from civet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.