I feel a bit like the kid outside the sweet shop (candy store), or toy shop. Allowed to look, but not to touch:)
We (the designers) feel that way too! Unfortunately both the design and the implementation are currently unfunded volunteer efforts, sandwiched in between our day jobs (or, increasingly, our search for a day job). That translates to a development process far slower than any of us would prefer. :-(
I find all of that extremely readable. Obviously your copius comments and context help, but it still bodes well for the future.
Thank-you. We've worked incredibly hard on keeping Perl 6 Perlish; tried to make it even more Perlish, in fact. Of course, threshing True Perl™ out the myriad of possibilities also contributes to the slowness of development.
I see you using (what I take to be) the P6 equivalents of P5s $a and $b.
Not quite. $^a and $^b are "placeholder variables". Every block in Perl 6 is really an anonymous subroutine. Putting a placeholder in a block is one way of giving that anonymous subroutine a parameter. Putting two in a block, gives the block/subroutine two parameters. Etc. etc.
Apart from that they are presumable properly scoped removing the old global clash fears,
Indeed. Like all subroutine parameters, they are lexically scoped to the body of the subroutine. In this case, to the block itself.
are they limited to just those two?
No. Any subroutine can have any number of parameters. Hence, any block can have any number of placeholders.
if I need to look at more than two elements of the argument array at a time (eg. a moving averages calculation) can I get to them through $^c, $^d etc?
You can specify as many placeholders as you like. However, the reduce built-in will not compute a moving average for you. It takes the data list you provide and successively extracts as many elements as there are parameters to the reduction block. To get a moving average, or moving maximum, or moving whatever, we'd need a function that takes an N-argument subroutine and moves it over a window. For example:
sub moving (&func, *@data) { # Note: "arity" means how many params the sub takes my @results; for 0..@data-&block.arity -> $from { my $to = $from + &block.arity - 1; push @results, func(@data[$from..$to]); } return @results; } @average_3 = moving { ($^x+$^y+$^z)/3 } @values; @average_4 = moving { ($^w+$^x+$^y+$^z)/4 } @values; @local_max_3 = moving { max $^x, $^y, $^z } @values; # etc.
Will @args (and @values) be implemented as a list or an iterator?
Arguments passed to a *@parameter are passed lazily, as an iterator tied to an array interface.
Do you have any feel for whether calling subs in P6 will have a lower overhead than P5?
That's a core design goal.
Does multi infix:max= happily combine with the multi max subs above?
Yes. That's exactly why I wrote it that way. ;-)

BTW, if anyone wants more detail, most of this is described in Apocalypse 6, summarized in Synopsis 6, and explained in the forthcoming Exegesis 6.


In reply to Re: Re: Re: Re: Re: A set of new operators. In keeping with the design of Perl? by TheDamian
in thread A set of new operators. In keeping with the design of Perl? by BrowserUk

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.