Larry Wall wrote:
> Jonathan Lang wrote:
> : It also occurs to me that traits can be thought of
> : as adjectives (thus the "is <trait>" vs. "is a <class>" distinction) -
> : another way to attach an adjective to a noun in English is to prepend
> : it to the noun:
> :
> : my Dog $Spot is red;
> : my black Cat $Tom;
> : my thoughtful $Larry is overworked;
> :
> : where red, black, thoughtful, and overworked are traits.
> :
> : Or is this too much?
>
> It's not too much for English. :-)
>
> But it is a little confusing in Perl because people might think
> $Larry returns things of type "thoughtful", rather than thoughtful
> being applied to the container type.
Then again, this is the exact same sort of confusion that could occur with
C<is>: sometimes it adds a trait, and other times it results in single or
multiple inheritence. If people can be trusted to keep them straight
there, I don't see why the prepended version would be any more difficult.
> And
>
> my black Cat $Tom;
>
> would be taken to mean something like:
>
> my $Tom returns (Cat is black);
>
> rather than
>
> my $Tom is black returns Cat;
>
> Maybe that's okay, but we haven't really talked about applying traits
> to classes outside of declarations, and what that would denote.
A somewhat more serious example:
my const Num $pi = 3.141592653589793238462643383279502884197169399;
would be equivelent to
my $pi
is const
returns Num
= 3.141592653589793238462643383279502884197169399;
unless you want to define an anonymous class representing a constant
number.
=====
Jonathan "Dataweaver" Lang
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/