Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Post-operator question mark #114

Closed
stuartpb opened this issue Jul 31, 2019 · 6 comments
Closed

Post-operator question mark #114

stuartpb opened this issue Jul 31, 2019 · 6 comments
Labels
alternative syntax past ideas and discussions about alternative syntaxes

Comments

@stuartpb
Copy link

stuartpb commented Jul 31, 2019

I looked at all the previous alternative syntax proposals, and none of them seem to propose using .?, [?, and (? as the chaining operators, as I proposed on WICG about three years ago.

Wouldn't this make more sense, as the only case where this overlaps currently valid syntax is the 1.?foo:bar case described in other issues that only propose variations of .? for the other two operators (which, as noted in those issues, is evitable by not allowing this syntax on numbers)?

@ljharb
Copy link
Member

ljharb commented Jul 31, 2019

Hmm - it might be confusing whether obj[?foo] applies the ? to the object or to the foo variable?

@claudepache claudepache added the alternative syntax past ideas and discussions about alternative syntaxes label Jul 31, 2019
@claudepache
Copy link
Collaborator

Mmh, I’m sure that someone somewhere proposed that syntax, and that I explained why I didn’t like it, but I cannot find it... But @ljharb expressed my main objection in fewer words than I would have been able to.

Also, someone proposed that in a past poll about preferred syntax, but the option wasn’t very popular...

@jridgewell
Copy link
Member

Discussed in #61

@stuartpb
Copy link
Author

stuartpb commented Aug 2, 2019

#61 doesn't discuss .?, [?, and (? though - it discusses .?, .?[, and .?(.

The reason I think the former is superior to the latter (or ?., ?.[, and ?.( as are currently proposed) is because it doesn't introduce a . to the chained-index-and-call operators, which wouldn't have a . in their non-chained versions.

@Zarel
Copy link

Zarel commented Aug 2, 2019

[? is mentioned in #61 (comment)

Overall, the arguments in #61 (which are mostly about how ? makes more sense before . than after) apply equally well to [? and (?.

To be fair, you could make an argument that that's worth not having the weird dot in ?.[ and ?.( – but again, it was proposed in the poll and near-unanimously rejected, so I seriously doubt anyone would think it's worth revisiting after Stage 3.

@claudepache
Copy link
Collaborator

To be fair, you could make an argument that that's worth not having the weird dot in ?.[ and ?.( – but again, it was proposed in the poll and near-unanimously rejected, so I seriously doubt anyone would think it's worth revisiting after Stage 3.

Indeed.

Syntax has been discussed to death in the past, and we’ve reached rough consensus on the least bad option. I’m closing this issue in order to make clear that, as of now, the proposed amendment has about zero chance to be accepted, in absence of very strong and improbable reason. Thanks for your interest.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
alternative syntax past ideas and discussions about alternative syntaxes
Projects
None yet
Development

No branches or pull requests

5 participants