Chip Salzenberg writes:
> I'd like to annotate Perl 6 parameters and other entities using
> traits, since that's the best way (I know of) to have them appear
> immediately in the text of the program where they are.
> 
> Supposing I had a "doc" trait, could I say:
> 
>     sub f2c (Num $temp doc<Temperature in degrees F>)
>         doc<Convert degress F to degrees C>
>     {...}
> 
> Or would I be forced to spell it  doc('stuff')  ?

Well, first you need an `is` somewhere in there.  And after that I think
you'll need to do it in doc('stuff') form.  If we did allow doc<>, then
this:

    is doc<Convert degrees F to degrees C>

Would mean:

    is doc('Convert', 'degrees', 'F', 'to', 'degrees', 'C')

Which I expect is not what you intended.  But if we start allowing that
everywhere, then I think that we'd have to do it for subs, too:

    sub foo([EMAIL PROTECTED]) {...}
    foo<a b c d e>

And that isn't an implausible thing to do, but it forbids what might be
a common practice:

    $foo.hash{'a'}

Replacing it with the more convoluted:

    $foo.hash(){'a'}

And it essentially wouldn't allow objects that could be treated as both
subs and hashes... not that that's a huge loss.  Anyway, I think you'll
have to stick with is doc('...').

Luke

> -- 
> Chip Salzenberg            - a.k.a. -            <[EMAIL PROTECTED]>
>          Open Source is not an excuse to write fun code
>             then leave the actual work to others.
> 

Reply via email to