Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: What's so bad about &function(...)?

by TimToady (Parson)
on Dec 09, 2005 at 18:04 UTC ( #515614=note: print w/replies, xml ) Need Help??

in reply to Re: What's so bad about &function(...)?
in thread What's so bad about &function(...)?

Another reason it doesn't much matter is that, to make things more consistent, we're changing what it means in Perl 6. The notation no longer has anything to do with how the arguments are processed--there are now flattening operators for that. Instead, when you say &foo, you're explicitly marking "foo" as a noun rather than a verb. As a noun, it always returns a scalar reference in scalar context, and like any other reference, it is not dereferenced unless you do so explicitly. In the case of &foo, it is not called unless you say &foo() or some such.

Interestingly, this completely removes the Perl 5 distinction between foo(1,2,3) and &foo(1,2,3). Those are handled identically in Perl 6. What changes is the meaning of bare &foo. You now always have to pass @_ explicitly if that's what you mean.

  • Comment on Re^2: What's so bad about &function(...)?

Replies are listed 'Best First'.
Re^3: What's so bad about &function(...)?
by Perl Mouse (Chaplain) on Dec 09, 2005 at 22:46 UTC
    In Perl5, if you have arguments to a function, the parenthesis are optional if you don't use the & sigil (unless of course they are needed to prevent misparsing). However, if you use &foo to call a sub, and you want to call it with arguments, the parenthesis are mandatory.

    Will you be able to do:

    &foo 1, 2, 3
    in Perl6?
    Perl --((8:>*
      Nope, Perl 6 still has to be picky about when it is expecting a term and when it is expecting an operator. It's vaguely possible we could allow
      &foo: 1, 2, 3
      however, since there are already other cases where a colon allows us to omit the parens. Can't say it's high on my list of priorities though.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2021-02-25 20:10 GMT
Find Nodes?
    Voting Booth?

    No recent polls found