I checked some more time in
Dart , the idea is good, but many things, so to say, are not clear.
I want to discuss the concept of
metadata . Which I tried to find an application for and I think there is something in it, but the implementation of access to metadata is very bad. Especially for a new language that had to take into account existing experience, etc. etc.
Those. if you are from python (like me) then the behavior of this system is exactly the opposite of the intended one. These are not decorators and the easiest way to access them is from an object being decorated (annotated) (function, class, etc.). Well, it's easier -
it is figurative . In fact, you need to take three actions to get the value — get the object mirror (
InstanceMirror
), get the object class mirror (
ClassMirror
) from the object mirror and look in the metadata for what we stuffed into the object metadata ...
')
The solution through this metadata system of typical problems solved by decorators looks unreasonable at all. For example, there is the
bloodless framework, which, as the author writes, is deeply inspired by the Pythonic
Flask 'om. There, routing, interceptors of requests and error handlers are specified through metadata ... Since When setting metadata, nothing happens at all except creating the metadata itself - the only way to collect what they are attached to is to sort through EVERYTHING! And here
it is done - in the cycle mirrors of everything in the field of visibility get over, each instance searches for metadata and checks for compliance with the necessary types of metadata ...
Those. I think it is, to put it mildly, not right - the metadata is clearly not for that.
As I understand it, they are more likely to be a spot check. Those. when an object can have certain metadata according to API, recommendations, etc. For example, the functions of the above-mentioned routing with metadata on methods / urla / types should be collected into the list by hand and thrust into the configurator. The configurator knows what metadata to expect from the functions and forms the routing table. Well, as an example ...