On 26 November 2012 18:17, Manu <[email protected]> wrote: > On 26 November 2012 17:44, Adam D. Ruppe <[email protected]>wrote: > >> On Monday, 26 November 2012 at 15:39:35 UTC, Manu wrote: >> >>> Properties look like variables. How do I distinguish properties from >>> proper variables? >>> >> >> I think this will do it: >> >> import std.traits; >> bool isProperty = (functionAttributes!(S.P) & >> FunctionAttributes.property) ? true : false >> >> >> >> The way that works in the implementation is checking the mangled name of >> the function. I wouldn't try anything else because any other difference >> between a property and a variable is arguably a bug since they are supposed >> to be mostly interchangable! >> > > That's weird. Why would I call functionAttributes in something that I > can't even identify as a function? That's almost self-defeating... but as > long as functionAttributes will tolerate being called with basically any > argument, function or otherwise, then I guess this is okay... >
And fail! functionAttributes breaks when I pass basically anything that's not a function >_<
