<div class="gmail_quote">On 6 April 2012 15:58, Steven Schveighoffer <span dir="ltr"><<a href="mailto:schveiguy@yahoo.com">schveiguy@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Fri, 06 Apr 2012 03:54:15 -0400, Walter Bright <<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@digitalmars.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 4/6/2012 12:49 AM, Alex Rønne Petersen wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What about type declarations? I think those ought to be supported too. E.g. it<br>
makes sense to mark an entire type as @attr(serializable) (or the inverse).<br>
</blockquote>
<br>
<br>
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.<br>
</blockquote>
<br></div></div>
I think there is a huge misunderstanding here.<br>
<br>
A type constructor alters a type.  Annotations are not type constructors.<br>
<br>
for example:<br>
<br>
class C {}<br>
<br>
@foo class D {}<br>
<br>
@foo C c;<br>
@foo2 D d;<br>
D d2 = d;<br>
<br>
In all these cases, the @foo or @foo2 affects the *declaration*, not the *type*.  So:<br>
<br>
1. D's type is not affected, it's still class D.  But an annotation has been stored on the *symbol* D, such that it can be looked up later.<br>
2. annotations on variables do *not* affect the type of the variable.  The assignment to d2 works fine.<br>
3. The following symbols have annotations attached to them:<br>
  C: none<br>
  D: @foo<br>
  c: @foo<br>
  d: @foo2<br>
  d2: none<br>
<br>
Note that d and d2 have no annotations attached even though they are of type D.  Because the type isn't affected by annotations.<br></blockquote><div><br></div><div>Just to clarify, typeof(d) and typeof(d2) (ie, both D's) are still annotated with foo, right? This is precisely how I imagine it to be.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">An annotation is simply metadata, stored in the compiler, and looked up via compiler directives.  Optionally (and I would encourage this), TypeInfo would store annotations on type declarations for retrieval at runtime.<br>
</blockquote><div><br></div><div>I agree, and I would also encourage this.</div></div>