custom attribute proposal (yeah, another one)

Manu turkeyman at gmail.com
Fri Apr 6 08:06:55 PDT 2012


On 6 April 2012 17:53, Timon Gehr <timon.gehr at gmx.ch> wrote:

> On 04/06/2012 04:23 PM, Steven Schveighoffer wrote:
>
>> Why should we be restricted to only structs? Or any type for that matter?
>>
>>
> A restriction to only structs is not a restriction because structs can
> have arbitrary field types.
>
>
>  The benefit to using CTFE functions is that the compiler already knows
>> how to deal with them at compile-time. i.e. less work to make the
>> compiler implement this.
>>
>>
> It is exactly the same amount of work because CTFE is able to execute
> struct constructors.
>

The only real difference I see, is at the end of the day, the one level of
indirection (the function call) allows you to create an attribute with a
different name than struct that defines it. Otherwise they would seem to be
functionally equivalent.
Chances are, the creator function would just execute the struct's
constructor internally anyway. But maybe the function approach has an
effect on the simplicity of the expression for a simple attribute, like a
single bool?
I suppose a single bool attribute wouldn't work so well declared the
constructor way, it really does need the name it would inherit from the
creator function...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120406/12910325/attachment.html>


More information about the Digitalmars-d mailing list