| What's wrong with the following code? https://github.com/dart-lang/bleeding_edge/blob/master/dart/... =============================== class _IntegerImplementation extends _Num { @inline(INLINE.INTRINSICS) // <============================
int _bitAndFromInteger(int other) native "Integer_bitAndFromInteger";
}=============================== The same method in CORE_INTEGER_LIB_INTRINSIC_LIST https://github.com/dart-lang/bleeding_edge/blob/master/dart/... =============================== V(_IntegerImplementation, _bitAndFromInteger, \
Integer_bitAndFromInteger, 504496713) =============================== If Dart VM can use "patch class" declarations then why this "@inline" should be considered as a bad? Maybe your answer in that the "Dart VM ignored all kind of annotations (including type annotations) why it should use this approach". P.S. This is a not a direct problem of dynamism (ignore annotations even if they hard coded in source). Problem in that the Dart VM does not want rely on annotations (dynamism is better, determine everything at runtime or from magic lists). |
Annotation like that is not enough for intrinsics. You would still need to provide some way of detecting in the compilation pipeline and intrinsifier that method you are looking at is indeed `Integer_bitAndFromInteger`. In this particular case you could look at the name of the native, but that does not work with those intrinsified methods that have Dart bodies. In those cases it would have to be @intrinsic("name of the intrinsic").
Right now we can write C++ code like this:
If we start to relying on strings - this code will become less readable (or alternatively you would have to map strings into C++ enumeration which would require a list quite list one of the above).To be honest aesthetically I like annotations, so I would like to use them to replace these lists, but that does not really solve anything or improve much. Even more: there is really no fundamental difference between having an annotation and a list like that, so I don't really understand what bothers you about these lists.
> (dynamism is better, determine everything at runtime or from magic lists)
Annotation would be no less magic (and not available to the user code anyways).