develooper Front page | perl.perl5.porters | Postings from September 2012

Various questions about named parameters

Thread Next
From:
Father Chrysostomos
Date:
September 16, 2012 12:17
Subject:
Various questions about named parameters
Message ID:
A1EFA6A8-8073-4F6F-826D-18A5BFEC4BFF@cpan.org
I think these questions need to be asked:

1. Do we really want to prevent custom call checkers from extending prototype syntax?

2. Do we really want named parameters and parsing prototypes to occupy the same syntactic niche?

3. Should a named parameter list *be* the prototype (accessible through prototype(\&sub), though not necessarily affecting parsing)?

4. Do we really want to create lexical variables without an explicit ‘my’?

5. One suggestion about future extension is that we can easily add ‘:rw’ or ‘:alias’ or ‘is rw’ later, so we don’t have to worry about it now.  But do we really want to have a separate minilanguage here, or should it try to follow existing Perl syntax as far as possible?

I have nothing against this feature, as long as it remains an experimental feature until those questions are answered.

Here is another question:

6. Why not leave @_ alone and have goto use the named parameters when called from inside a sub that has them?


I was planning to stop here and leave the proposals to others, but then I started thinking:

sub foo my($foo, $bar, $baz) {
    ....
}

sub foo my($foo, \$bar, $baz) {
    ....
}

(comparable to (my $foo, \my $bar, my $baz) = ($_[0], \$_[1], $_[2]); i.e., an explicit \ implies a \ on the rhs).

And this:
    my(\$x);

in addition to the obvious:
    \my($x);


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About