Today I was reading S06 from
http://dev.perl.org/perl6/doc/design/syn/S06.html, and I have some
perplexities on what's written there.

1) it's written:

    $pair = :when<now>;
    doit $pair,1,2,3;   # always a positional arg
    doit *$pair,1,2,3;  # always a named arg

   but also:

    To pass pairs out of hash without their being interpreted as named
parameters, use

      doit %hash<a>:p,1,2,3;
      doit %hash{'b'}:p,1,2,3;

    instead.

   I interpret the last sentence as meaning that:

     $hash<a>=:a<2>; doit %hash<a>;

   would be equivalent to:

     doit :a<2>

   which contradicts what is written earlier... I'd assume I'd have to
write:

      doit *(%hash<a>);

   for the pair to be used as a named argument. What am I missing?

2) Consider:

     doit %*hash;   # 1 arg, the global hash
     doit *%hash;   # n args, the key-value pairs in the hash

   I think I'll use a lot of C-t while writing Perl6 code...

3) What does the second line in:

      push @array, :a<1>;
      say *pop(@array);

   mean? I'd parse it as 'say (*pop)(@array)', that is, call the global
'pop' subroutine. But the text around this example seems to imply that
it is to be parsed as 'say *(pop(@array))', i.e. execute 'pop' and splat
the result. What gives?

4) It's written:

       (Conjectural: Within the body you may also use exists on the
parameter name to determine whether it was passed. Maybe this will have
to be restricted to the ? form, unless we're willing to admit that a
parameter could be simultaneously defined and non-existant.)

   Ok, this is 'conjectural', but... if i don't pass a parameter in an
invocation, and that parameter had a defined default, that it would be
both defined and non-passed... here I'm sure I'm missing something

5) while talking about pipes, it says that

     (0..2; 'a'..'c') ==> my @;tmp;
     for @;tmp.zip { say }

   produces

      [0,'a']
      [1,'b']

   etc. Right. But then it says:

     for @;tmp.each -> $i, $a { say "$i: $a" }

   as far as I understand, this should say

     0: undef
     'a': undef

   etc., since 'each' is visiting the multidimensional array 'by rows',
and producing 1 value at a time, which when bound to the 2-ary signature
would leave the $a parameter without a value, and so undef (I'm assuming
that pointy sub positional parameters are implicitly optional, otherwise
that statement would be a run-time error). I'm pretty sure I don't know
what 'each' does...

6) It's written:

     Every lexical scope gets its own implicitly declared @; variable,
which is the default receiver.

   To me, that is a variable with a null name ('@;' being a twigil).
Should it not be @;_ ?



I'll continue reading...

--
        Dakkar - <Mobilis in mobile>
        GPG public key fingerprint = A071 E618 DD2C 5901 9574
                                     6FE2 40EA 9883 7519 3F88
                            key id = 0x75193F88

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to