Custom attributes (again)
Timon Gehr
timon.gehr at gmx.ch
Fri Apr 6 04:03:45 PDT 2012
On 04/06/2012 12:16 PM, Walter Bright wrote:
> On 4/6/2012 1:15 AM, Alex Rønne Petersen wrote:
>> On 06-04-2012 09:54, Walter Bright wrote:
>>> On 4/6/2012 12:49 AM, Alex Rønne Petersen wrote:
>>>> What about type declarations? I think those ought to be supported too.
>>>> E.g. it
>>>> makes sense to mark an entire type as @attr(serializable) (or the
>>>> inverse).
>>>
>>>
>>> That would make it a "type constructor", not a storage class, which we
>>> talked about earlier in the thread. I refer you to that discussion.
>>
>> To be clear, I don't want annotations on a type declaration to
>> actually affect
>> the type. Annotations are just that: Annotations. Nothing else.
>
> What would an annotation on a type mean if it does not affect the type?
I don't get that either, it has to affect the type. It does not have any
effects on the semantics of instances on the type though. Name mangling
can stay the same though.
> Would it just be baggage carried along?
Yes.
> If so, how would that affect types inside of a template, where the type was passed as a type
> constructor?
How do you pass a type as a type constructor?
> How would type inference work?
Just as it does now.
> Would an alias carry or drop the baggage?
Carry. An alias does not change the referenced symbol.
> How would overloading work?
> How would covariance work?
As they do now. Custom attributes don't have semantic meaning recognised
by the compiler. They are just data.
> It's a maze of complex decisions.
>
I think you can add a list of annotations to the class in the AST that
represents a declaration (the common superclass of all declarations) and
everything will just work.
>
>> Does a design like that still give rise to the semantic issues you
>> mentioned (it
>> isn't clear what those are)?
>
> Yes.
>
> (I know Java does this. But Java has a trivial type system compared with
> D. It doesn't even have type aliases. It doesn't have type constructors.
> Etc.)
I think there is some sort of communication problem, because the feature
that is being requested is quite simple. It would probably be valuable
if you could point out the issues you see in detail (using example code.)
More information about the Digitalmars-d
mailing list