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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.