Skip Menu |

This queue is for tickets about the Kavorka CPAN distribution.

Report information
The Basics
Id: 102496
Status: rejected
Priority: 0/
Queue: Kavorka

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.036
Fixed in: (no value)



Subject: Parameters cannot be used in defaults
It can be useful to use required parameters in the defaults of later optional ones, especially if they're positional.  Kavorka does not support this.  Method::Signatures and Function::Parameters do.

$ perl -wle 'use Kavorka;  fun test ( $one, $two = $one + $one ) { print $two } test(2)'
Use of uninitialized value $one in addition (+) at -e line 1.
Use of uninitialized value $one in addition (+) at -e line 1.
0

$ perl -wle 'use strict; use Kavorka;  fun test ( $one, $two = $one + $one ) { print $two } test(2)'
Global symbol "$one" requires explicit package name at -e line 1.
Global symbol "$one" requires explicit package name at -e line 1.
BEGIN not safe after errors--compilation aborted at /Users/schwern/perl5/perlbrew/perls/perl-5.18.1-thread/lib/site_perl/5.18.1/Kavorka/TraitFor/Parameter/optional.pm line 1.
Compilation failed in require at /Users/schwern/perl5/perlbrew/perls/perl-5.18.1-thread/lib/site_perl/5.18.1/Module/Runtime.pm line 317.
I don't consider this to be a bug, but a limitation, and it's already documented, with a workaround. It's like how in Perl you can't do this: my ($one, $two) = (1, $one + $one);