tc39/proposal-optional-chaining

List Dart in prior art

aghassemi opened this issue · 7 comments

Dart lang has optional chaining with the same syntax as the proposal, I think it should be listed as prior art. Please see http://blog.sethladd.com/2015/07/null-aware-operators-in-dart.html

Indeed Dart has ?. but it doesn't have ?.[] which is the one that is the most contentious.

No, ?.() is the most contentious. Bracket access is a necessity given that symbols exist.

Bracket access is a necessity given that symbols exist.

I am not talking about "bracket access", I am talking about the (multi) token currently chosen for it.

ah, fair enough

I’ve tried the feature in https://dartpad.dartlang.org. It doesn’t seem to support the same short-circuiting semantics in chains like: a?.b.c

Dart doesn't have ?.[] but it expose elementAt as alternative to [] so arr?.elementAt(ind) handles the use-case. I personally like ?.[] but not the . in there. Why not arr?[index] like C#?

Correct, no short-circuiting or ?.() support in Dart.

Regardless, I don't think Dart needs to match everything here to be listed as prior art. AFAIK C# doesn't have ?.() and relies on ?.invoke() for calling delegates.

Why not arr?[index] like C#?

First item in the FAQ, https://github.com/tc39/proposal-optional-chaining#faq. It's not possible because it creates ambiguity with currently valid syntax.