-
Notifications
You must be signed in to change notification settings - Fork 38
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
this keyword as a dynamic return type #147
Comments
Wasn't this resolved with the
And, if you want to document changes:
|
I assume that @ericelliott I am talking about a dynamic type. As explained here:
As I said in the nota bene up there that would require to return unions. Also your example can't work precisely because the signature of the function that I am talking about is not bound (i.e it may have different call-sites). What are our priorities? Are the use cases for this feature too rare? PRO
CON
|
Essentially, it is the same thing as this::method() => this But you need the |
I like this, it's explicit.
I thought we encouraged type variables to be one char long:
|
related: #68
example
You have a fluent interface but one of the method X is slightly restrictive and doesn't return
this
but a subset of itsthis
. In this case if the next method Y returnsthis
it will share its constraints.problem: if that method Y may also follow another method Z that returns
this
, its return type becomes dynamic.solution: introduce a
this
return typeNB
It would be impractical to require the user to provide all the possibilities as unions.
It's the job of the static type checker; it should be able to infer the correct type from the current
this
.proposal
The text was updated successfully, but these errors were encountered: