Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Poor Man's Perl6 Exegesis (you get what you pay for)

by mikfire (Deacon)
on Jan 24, 2002 at 23:45 UTC ( [id://141297]=note: print w/replies, xml ) Need Help??


in reply to Poor Man's Perl6 Exegesis (you get what you pay for)

I am uncertain if I should update my previous node or not. As I am attacking a seperate portion of this, I believe I am correct in making a new node.

sub myimport($exp_from : *@symbols=() : *@options=())
What does this do? I have been over the related Apocalypse and Exegesis ( part 3 ) and I think the idea here is to allow myimport to be called with lists instead of arrays.

According to TheDamian in Exegesis 3, page 1, the @ will cause perl6 to expect either an array or an array reference as the parameter. If we were to declare a perl6 sub like this:

sub foo( @bar )
and called it like this:
&foo( "a", "b" );
we would generate an error ( at compile time? ).

If we really want foo to be called with a list, we need to put the flattening star in the sub definition:

sub foo( *@bar )

But, later on in the same tome, we are told that this will have the standard perl5 affect of slurping the remainder of the parameters.

I am guessing this to be an error on BrentDax's part. I believe BrentDax was attempting to allow myimport to be called with lists, but forgot that the flattening star would behave exactly as we expect from perl5. If I have missed something, I would really appreciate being corrected.

update: Changed a bit of wording in the last paragraph. Mik
mikfire

Replies are listed 'Best First'.
(Ovid) Re(2): Poor Man's Perl6 Exegesis (you get what you pay for)
by Ovid (Cardinal) on Jan 25, 2002 at 00:08 UTC
    sub foo( @bar ){...} &foo( "a", "b" );

    As I read things, yes, this is an error. The flattening star will be necessary to slurp up the rest of the goodies. I suspect that this is going to be a source of bugs for many people switching to Perl6. Also, I suspect the following will trip people up:

    @*ARGS; # was @ARGV

    The star between the sigil and the variable name, I believe, is how we will now be referring to special globals. Thus, @*ARGS != @ARGS.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      Not true. @*ARGS and @ARGS are the same thing, unless you define a new @ARGS in your scope. If that happens, you can still access the global @ARGS as @*ARGS.

      =cut
      --Brent Dax
      There is no sig.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://141297]
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 2025-06-16 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.