I finally got arround to reading Exegesis 6, and for the most part it's all cool and everything, and makes a lot of sense, but then something jumps out at me in the section "You Are What You Eat -- Not!"...
...Perl 6 allows us to specify both the storage type of a variable (i.e. what kinds of values it can contain) and the implementation class of the variable (i.e. how the variable itself is actually implemented).
The is keyword indicates what a particular container (variable, parameter, etc.) is — namely, how it's implemented and how it operates. Saying:
sub bark(@dogs is Pack) {...}specifies that, although the @dogs parameter looks like an Array, it's actually implemented by the Pack class instead.
Now, the part about using "is" to indicate the acctual implimentation of a container makes sense to me for variables -- except when those variables are sub parameters, because parameters (by default) are just aliases to the arguments. It seems like the only way you should be able to say "@dog is SomeClass" is if you also say "is copy" so that perl creates @dog as an instance of SomeClass and copies all of the items in the argument container into @dog (using whatever STORE method is defined in SomeClass.
Does that sub bark(@dogs is Pack) seem wrong to anybody else?
(The only way i can think of that it might work, is if the is SomeClass attribute of a parameter indicates that an exception should be thrown if something other then SomeClass is passed in -- but that seems like a non-standard use of the "is" keyword)
In reply to Ex6: Using "is" on aliased sub parameters? by hossman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |