On Jan 12, 2011, at 1:44 PM, Johan Björklund wrote:
There is no real need for this when it is so easy to look into objects, iterate, etc.
While it is true that it's simple to inspect things, I don't know I'd go so far as to say what Cohen's suggesting wouldn't be highly useful. There's something to be said for not having to "roll your own" every time you want to exchange data.
A few years ago I brought up the idea of adding the ability to add metadata to a class or its members, much like "they" do it in .NET or similar to annotations in Java. While it wouldn't solve the problem on its own, it would make it much simpler for frameworks that actually do this sort of thing to configure themselves without writing a lot of extra code. I envisioned a generic syntax in which metadata could be written inline (perhaps stored as a mapping for each member which has metadata as well as one for the class itself) and methods that enabled code to retrieve the metadata specified for a given class or member.
One might argue that you could do this already, which is true to a certain extent. However, the syntax would be more verbose and the inline aspect would be lost, as would the immutable and somewhat camouflaged nature of the data.
I can think of all kinds of uses for this sort of thing (oh, that and the ability to query a member about it's type, which I think is still pretty tricky to do well). If I recall correctly, there was a little discussion about it but there wasn't much traction at the time. I don't think anyone came out and said it was a bad idea, but that might have been the subtle message.
Does anyone have any thoughts about this?
Bill