This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: annotations for Kawa
* Per Bothner [2010-12-05 20:01] writes:
> On 12/05/2010 11:48 AM, Helmut Eller wrote:
>> * Per Bothner [2010-12-04 16:08] writes:
>>> The next issue is the syntactic support. As suggested before,
>>> the most logical syntax for an individual annotation is probably:
>>>
>>> (@AnnotationType keyword1: exp11 ... keywordN: exprN)
>>>
>>> where AnnotationType is an annotation type name (identifier),
>>> and exp1..exprN are compile-time-constant expressions.
>>
>> Is the @ new lexical syntax or just a naming convention?
>
> It's a naming convention - I don't intend to change the reader.
> Instead, this would be "recognized" by Scheme.checkDefaultBinding
> - the same place where we also recognize TypeName? and quantities.
So @AnnotationType denotes the annotation AnnotationType
like <FOO> denotes the type named FOO.
> Thus note that unlike Java, a space between '@' and AnnotationType
> would *not* be allowed.
>
> An identifier that starts with '@' would be translated by
> Scheme.checkDefaultBinding to something roughly equivalent to:
>
> (lambda args (apply make-annotation AnnotationType args))
>
> This would need to be "inlined" at compile-time for the annotations
> to be attached to Declarations and emitted in .class files.
>
> (I haven't actually implemented this, so it might turn out to be
> more problematic than expected. We'll see.)
Can macros expand to annotations? E.g. in
(define (a) (b) (c))
could b be a macro that expands to (@Deprecated) ?
Helmut