Pardon me but I am interested in this module , so I would have some
comments and some questions.
On Wed Oct 08 19:16:30 2008, schwern@pobox.com wrote:
Show quoted text> Slaven_Rezic via RT wrote:
> > When using Deparse, I see that the parameter handling is resolved
> like this:
> >
> > my $a = $_[0];
> > my(@b) = @_[1 .. $#_];
> > my $c = $_[2];
> >
> > Maybe it would be better to use my(@b) = @_[1 .. $#_-1]; instead
> here?
> > Or just forbid any arguments after a @array argument?
>
> There's almost no error handling on arguments right now. Just
> required and
> named parameters. There's plenty of fun things you can get it to do.
>
> A prototype of ($a, @b, $c) is possible, just so long as everything to
> the
> right of the array is required. I think there's enough information in
> the
> current signature logic to figure that out.
This particular case should be easy to figure out.
However there could be ambigous cases such as:
($a,@b,$c,@d).
The problem with this is that you don't know how big b is and how
big @d is.
But there is also a case in which this shouldn't be ambigous.
When you pass it 4 parameters it's pretty clear that one goes
into $a , one into @b , one in $c and one in @d.
If you pass it 5 however it starts getting weird.
The same story can be said for ($a,@b,@d,$c).
Can subs have signatures with hashes as parameters ?
(didn't see much of that in the docs)
Show quoted text> However it does have an air of
> desperation about it. As if the rule is "make it fit however you
> can".
> Wedging an array in the middle of an argument list is less necessary
> with
> named parameters and aliasing. ($a, \@b, $c) makes more sense as does
> ($a,
> $c, :\@b).
>
Could the module also support parameter de-construction ?
Like we have in Javascript ( recently )
and Prolog ( but here we will have just one unification because
we cannot afford to be ambigous , not in Perl that is).
www.cefns.nau.edu/~jg455/classes/s09/cs396/pdf/10_prolog.pdf
Or for javascript it's called "Destructuring assignment"
https://developer.mozilla.org/en/
New_in_JavaScript_1.7#Destructuring_assignment
Could we have these as well ?
If we did , you could write ($a,[@b],$c) and it @b would have
the needed value.
Is this implemented already or does it work the same with ($a,\@b,$c)
--
Your bugs , they are afraid of me.