Proposal: user defined attributes
Jacob Carlborg
doob at me.com
Wed Mar 21 07:57:06 PDT 2012
On 2012-03-21 14:54, Steven Schveighoffer wrote:
> On Tue, 20 Mar 2012 12:16:41 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> Maybe there's a better approach than flectioned. Consider the language
>> is frozen solid. How would you solve problems with it?
>
> I think the closest anyone has come is Jacob, with his orange library.
> Maybe he can respond to this point.
>
> -Steve
With Orange I'm doing everything with compile time reflection.
Flectioned was all about runtime reflection. It's possible to replace
methods with flectioned at runtime and do a lot of crazy things.
In Orange I'm using mixins, tupleof and stringof to accomplish most of
the compile time reflection. Example:
class Foo
{
int a;
int b;
mixin NonSerialized!(b);
}
serialize(new Foo);
"mixin NonSerialized!(b);" is expanded to:
static const __nonSerialized = ["a"];
The fields are enumerated and serialized using tupleof. It also checks
all structs and classes if they have "__nonSerialized" defined.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list