2 problems I can't get my head around

Manu turkeyman at gmail.com
Mon Nov 26 08:32:07 PST 2012


On 26 November 2012 18:17, Manu <turkeyman at gmail.com> wrote:

> On 26 November 2012 17:44, Adam D. Ruppe <destructionator at gmail.com>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 >_<
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121126/0290ac70/attachment.html>


More information about the Digitalmars-d mailing list