Closed mhevery closed 8 years ago
@jacob314 we'd like to do this, but are unclear on how to best represent the types for non-DDC users. E.g. for @mhevery's function declaration above, would we represent the return types best as dynamic /*=List<T>*/
, or rather as List /*<T>*/
?
dynamic
would be easier for us, but it might make API consumption worse for non-DDC users (I guess?). I'm also not sure what the impact on dart2js
would be from this.
Any advice?
@mprobst the function declaration above doesn't return a list, but one that did would look like:
List/*<T>*/ makeList/*<T>*/() => ...
There shouldn't be a case where you'd need to return a worse type for non-DDC users.
BTW:
List/*<T>*/
is shorthand for:
List<dynamic/*=T*/>
if the latter is easier?
thanks!
Sorry still broken because the output can not have spaces. Should be first/*<String>*/(...)
not first/* < String > */(...)
@vsmenon the whitespace thing (within a comment!) seems really surprising, maybe this is a bug in DDC? Also: is there grammar or spec for this?
I guess we should have an integration test using DDC...
@mprobst (and @jmesserly who actually implemented this)
I believe it's just the spaces at the ends that are problematic. We only interpret comments of the form:
/*<TYPE_EXPRESSION_LIST>*/
and /*=TYPE_EXPRESSION*/
TYPE_EXPRESSION
can have whitespace in it - first/*< String >*/
should be fine. It's just that we're filtering for /*<
or /*=
exactly to minimize accidentally picking up unintentional comments.
The actual proposed grammar is here: https://github.com/leafpetersen/dep-generic-methods/blob/master/proposal.md - but that has no comments. :-)
The temporary comment syntax is here: https://github.com/dart-lang/dev_compiler/blob/master/doc/GENERIC_METHODS.md
Generic method:
should translate to:
Notice the
/*=T*/
when you are saying thatdynamic
is actuallyT
vs/*<T>*/
when you are simply adding type information.Used as:
should translate to: