Hi Todd,

On 03/10/2018 02:14, ToddAndMargo wrote:
> sub postcircumfix:<[ ]>(@container, **@index,
>                         :$k, :$v, :$kv, :$p, :$exists, :$delete)
>
> 1  Why the <[]>?  I have always used [] with out the <>.
>    Why would I want to use one over the other?
>
> 2)  Where does it state that the <> is optional?


postcircumfix:<[ ]> is the "real name" of the [ ] postfix operator. In
this case the < > are just how it's quoted, i.e. this is how you
communicate to perl6 where the name starts and ends. It is also in other
operator's names, like infix:<+> for the + operator, or postfix:<++> for
the ++ postfix operator. If your operator itself contains a < or a >,
you can instead use ['blah'] for the quoting, like infix:['<'] for the <
operator. As you can see, it's more or less different ways to write what
is essentially a string. Just like you have "foo" and 'foo' but also
q<foo>, q«foo», and anything else you want to come up with.


> 6)  Where is the --> return described?


The "-->" part of the signature is optional. If there isn't one, it
defaults to Mu, which is the type that everything conforms to, i.e. the
sub or method that either has "--> Mu" explicitly, or has it by leaving
it out, may return absolutely whatever it wants.

After all, the "-->" part is a constraint, and it gets validated at
compile time every time a sub or method returns.


> Yours in confusion,
> -T


Hope that helps a little
  - Timo

Reply via email to