Skip to content

Remove the ?check operator #9097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DartBot opened this issue Mar 13, 2013 · 6 comments
Closed

Remove the ?check operator #9097

DartBot opened this issue Mar 13, 2013 · 6 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report

Comments

@DartBot
Copy link

DartBot commented Mar 13, 2013

This issue was originally filed by [email protected]


I propose to remove ?check operator (I believe it's called "argument existence test" or something like that in the spec).

Reason: in a sense, it allows optional parameters to have two observable values at the same time. If used, this affects API a lot, but there's no way for the API user to know. And there's no way to opt out. I personally believe that any function using this operator forms an ill-designed API.

Also, it breaks the way people were forwarding parameters to other functions for decades -- and there's even a proposal to add special syntax for that. Having to use special syntax just to forward parameters is highly error-prone and is likely to lead to style rules like "always use this forwarding syntax, 'cause you can't never know".

If this is deemed absolutely necessary (I've heard that maybe the DOM requires it), then I'd propose removing the possibility of optional parameters having two simultaneous values, and instead adding a possibility for optional parameters having no value. I believe this concept is much easier to grasp, and it would have to be visible on the API level (so that possible issues can be detected early).

@iposva-google
Copy link
Contributor

Added Area-Language, Triaged labels.

@iposva-google
Copy link
Contributor

Issue #9098 has been merged into this issue.

@DartBot
Copy link
Author

DartBot commented Mar 13, 2013

This comment was originally written by [email protected]


Agreed, this brings back dark memories of null and undefined in JavaScript, we should only support 1 notion of emptiness or non-existence and force API developers to develop their APIs around this and not distinguish between null and "not called with".

@munificent
Copy link
Member

I'm strongly in favor of this.

There are several people (both on the Dart team and off) whose current best practice is "do not use ?". I've been tempted on multiple occasions to even put that in the style guide, but haven't.

With the "?" operator, Dart has both null and undefined, and all of the complexity that that entails. At the same time, it does not make undefined first-class, which brings in all of the limitations of having a second-class piece of state in the system.

In return for this complexity, we get the ability to distinguish "explicitly passed null" from "did not pass an optional argument". I haven't seen evidence that that trade-off is worthwhile.

@lrhn
Copy link
Member

lrhn commented Mar 13, 2013

I also think that the ?-operator is cruft trying to fix a very specific problem, and doing it only half-way. As Bob says: we have undefined, but it's a half-assed feature, as opposed to a first-class value, so we now need to add more cruft to make the old cruft work.
I think Dart would be better off without it - the added complexity is larger than the benefits.

@munificent
Copy link
Member

Added Duplicate label.
Marked as being merged into #10466.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

4 participants