On Thu, 31 Mar 2005, Luke Palmer wrote:

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>

But if you are going to use doc('') in a million places, can you not also make doc a trait_verb and save a little typing? So:

role doc{
        sub *trait_verb:doc($container: $string) {

But what do I apply the role to? perhaps
        class Object does doc


        sub f2c (Num $temp doc "Temperature in degrees F") {...}

works(I think): trait_verb:doc is a sub, not a method, and so parens are not needed.

It works, but that doesn't read too well. We do need a verb there. "docs", perhaps? Or "gloss", which is both a noun and a verb?


Reply via email to