Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Yet Another Way To Get Involved With Perl6

by ank (Scribe)
on Jun 11, 2005 at 14:35 UTC ( [id://465806]=note: print w/replies, xml ) Need Help??


in reply to Yet Another Way To Get Involved With Perl6

A few days ago I was looking for a small task to help within Perl 6 development while learning it. After asking around, I started looking at the perl6-language archives and AES for reference. Wanting to try some code using loops, I read about zip(). I found a few different (and somewhat conflicting?) references to the ways it cuold be used:

zip(@a,@b,...) zip(@a;@b;...) zip(@a,@b,...,by=>3) zip(@a=>3,@b=>2,...)

It wasn't clear whether by should be supported or not, whether it should have semi-colons or commas as argument separators and whether the numeric options should work or were dropped entirely. As far as I could tell, the svn version of pugs only accepts the first form. I also found a discussion about zip() and weave() - but couldn't find weave() anywhere else.
Of course, I'm new to perl6, so I know almost nothing about how these should work within pugs or in a more finished perl6 (and I'm surely missing information!).
Having some documentation dealing with issues like these would help a lot of people in my position to get up to speed with it.

-- ank

Update Fixed grammar, spelling

Replies are listed 'Best First'.
Re^2: Yet Another Way To Get Involved With Perl6
by TimToady (Parson) on Jun 11, 2005 at 17:24 UTC
    It needs to be semicolon, but I don't know if Pugs handles semicolon lists correctly yet. When passed to a function not expecting semicolons, they're just treated as commas. But when passed to a function like zip() that is expecting them, semicolons delimit multiple input lists. Saying
    zip(@a;@b;@c)
    needs to be equivalent to
    zip <== @a <== @b <== @c
    There are no optional arguments to zip() that I'm aware of, but if there were any, they'd have to come in before the semicolon lists. In other words, semicolon lists are not ordinary positional arguments. They're a way of ordering multiple variadic inputs, invented originally to handle multidimensional slice subscripts, but since then generalized to work with any signature that recognizes them (though what exactly in the signature recognizes them is still somewhat open to negotiation).

    However, there are no general guidelines for how to document the as-yet undesigned parts of the design. The best you can do is to make a guess consistent with the current design and see if anyone carps about it. A certain willingness to be sincerely misguided goes with the territory. :-)

      Sounds very interesting -- I also read a bit on the supercomma (see below) -- I wonder how these will all fit together -- and I'll try to help find out :)

      Now, about the zip() issue, these are the sources:

      • Just semicolons, no mention of parameters: S04
      • Parameters, general discussion, weave() - see the 4 links after "Supercomma!" (it is an old discussion though).
      • Another example with parameters and commas:
        for zip(@colors=>2, @textures=>1) -> $color1, $color2, $texture { $mix = blend($color1, $color2); draw_circle($mix, $texture); }
        (source: Perl 6 and Parrot Essentials, 2nd edition, 4.3.2.3)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://465806]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-20 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found