improved auto generic type inference, proposal for backward compatibility. #1018
Replies: 6 comments
-
@MkazemAkhgary I'd prefer something like this However, what do you really mean by the following?
I'm not sure how having the colons there helps, can you think about a scenario where the other suggestions wouldn't suffice? |
Beta Was this translation helpful? Give feedback.
-
I suggested
|
Beta Was this translation helpful? Give feedback.
-
@MkazemAkhgary Fair enough. |
Beta Was this translation helpful? Give feedback.
-
Another idea is to use |
Beta Was this translation helpful? Give feedback.
-
@ghord Yup, this would be cool. :) |
Beta Was this translation helpful? Give feedback.
-
@agocke is investigating extending type inference to take constraints into account. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
this feature has been requested many times, #997
I'd like to propose a new syntax for improved generic type inference so that it will not be a breaking change. even though there are unusual scenarios where improvements in type inference can change behavior of existing programs.
use
<::>
notation so that compiler will use improved rules for type inference rather than using traditional rules.Side proposal:
this notation is appealing to me, alternatives would be
<>
or<*>
or a more explicit version
<,,,>
where number of commas should be equal to number of type parameters minus 1.maybe support it as partially specified type parameters. like
<*, int, double, *>
.Notice: my main proposed syntax is
<::>
but I wanted to open discussion further. I'm not saying all of these must be supported, only one of them to achieve same result with backward compatibilities.Its worth noting that traditional type inference works for most cases, but there are some cases that it just doesn't work, as already described, I think that
<::>
is short, concise and readable enough. also you are not forced to use<::>
all the time.note that
<::>
has always two colons, regardless of number of type parameters.Beta Was this translation helpful? Give feedback.
All reactions