On 3/8/12, H. S. Teoh <hst...@quickfur.ath.cx> wrote:
>       foreach (name; __traits(allMembers, typeof(obj))) {
>               static if (__traits(compiles, &__traits(getMember, obj,
>                               name)))
>               {
>                       alias typeof(__traits(getMember, obj, name))
>                               type;
>                       static if (is(type==function)) {
>                               // name refers to a function of type
>                               // 'type' here
>                       }
>               }
>       }
>
>> I've never had an easy time interacting with __traits.

Yesterday I've tried the same thing but it didn't work because I was
missing the &__traits call. With that in place, here's a very
hardcoded example of what you can do in D:

http://paste.pocoo.org/show/562933/

So now you can catch the exception if the object was uninitialized.
And you didn't have to modify the target class at all.

Reply via email to