-
Notifications
You must be signed in to change notification settings - Fork 73
Token and parser concideration #66
Comments
This appears a duplicate of #34. |
Yup very similar, I'll leave it open cause there is a bit of difference (otherwise I'd close it.) |
@aminpaks I don’t understand your proposal. For example, when I see So..., please reformulate your proposal by explaining the semantics instead of expected results of particular examples. I think the simplest way to explain it is showing the desugaring: obj.z?.[0] // obj.z == null ? undefined : obj.z[0] |
@claudepache thanks for your feedback. I updated my initial proposal and changed some stuff. Hope that's okay with you as I'm organizing my thoughts as I'm learning more... |
I wonder if the use of an exclamation point here might interfere with some recently introduced typescript features in 2.7... I do like how the bang plays out with arrays and functions...but syntactically, it might conflict with existing language features of TS, which might very well be viable proposals to ES in the future... |
I hear you, I was just trying to suggest a better syntax for more readability. For sure this conflicts with current existing TS code as |
I do like the chain of thought here, for sure. I am intrigued by your use of !, and the way you described the outcomes. That's the reason for these proposals. :) |
AFAIK there are 2 main usages of
Negation is orthogonal to the notion of optionality/uncertainty that is evoked by |
It could be other characters for that use case. The idea is To use |
Uh oh!
There was an error while loading. Please reload this page.
I'd like to introduce
!
with?.
as the tokens for this proposal.Please bear with me if this sounds a bit silly as I'm just brainstorming with you.
IMHO, the chaining syntax becomes less human readable when it uses the same token to access array indices and call functions:
If we'd separate the token usage to only access to properties:
and add a new must following token
!
to access array indices and functions, it becomes more readable:At this point there is only one case that I'm not sure how to solve it and that's functions in scoped/global variables. As the
!
must be a following of?.
this case makes less sense:Some more examples:
The text was updated successfully, but these errors were encountered: