Comments (5)
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.
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.
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.
Hmm, we may want to go for consistency with CoffeeScript then, or at least note it and have a compat flag.
from civet.
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)
- `<?` without whitespace compiles without the whitespace
- Slice operator doesn't handle operators with lower precedence than `+` properly
- CLI execute flag
- ternary requires space HOT 4
- `%/=` and `÷=` does not work
- can't use comma operator when indexing HOT 6
- Fat pipe (`||>`) does not play nice with typescript-eslint v8 HOT 2
- expressions in the middle of a comparison chain are evaluated twice HOT 1
- `‖=` does not work
- `!=` not supported in chained comparison
- multi assignment expressions are evaluated twice HOT 1
- CLI doesn't work globally
- sometimes space is required for lambda
- Object union type is misparsed HOT 2
- Postfix conditional with nested `(and)`/`(or)` conditions seems like it ought to work HOT 2
- Cannot read properties of undefined (reading '3')
- Debugging in VS Code HOT 4
- Non-identifier operators HOT 2
- Postfix `if`/`unless` in types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from civet.