Skip Menu |
 

This queue is for tickets about the MooseX-Method-Signatures CPAN distribution.

Report information
The Basics
Id: 52610
Status: open
Priority: 0/
Queue: MooseX-Method-Signatures

People
Owner: Nobody in particular
Requestors: ijw.bitcard [...] cack.org.uk
Cc:
AdminCc:

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



Subject: Default for arguments should allow 'undef'
Download (untitled) / with headers
text/plain 421b
(A matter of opinion, but here we go.) I tend to think of: sub x { my ($self, $arg) = @_; ... and method x($arg) { ... as being equivalent. They certainly look fairly equivalent. Thus, I find it annoying that I actually have to type method x(Item $arg) { ... Is there a reason that, by default, undef arguments are disallowed? Could the default behaviour be changed?
Subject: Re: [rt.cpan.org #52610] Default for arguments should allow 'undef'
Date: Wed, 09 Dec 2009 22:02:02 -0600
To: bug-MooseX-Method-Signatures [...] rt.cpan.org
From: Jonathan Rockway <jon [...] jrock.us>
Download (untitled) / with headers
text/plain 329b
* On Wed, Dec 09 2009, Ian Wells via RT wrote: Show quoted text
> I find it annoying that I actually have to type > > method x(Item $arg) { > ...
You don't have to type that. You can type "method x($arg?)". The ? modifier makes something optional. Regards, Jonathan Rockway -- print just => another => perl => hacker => if $,=$"
Download (untitled) / with headers
text/plain 1.1k
On Wed Dec 09 23:02:21 2009, jon@jrock.us wrote: Show quoted text
> * On Wed, Dec 09 2009, Ian Wells via RT wrote:
> > I find it annoying that I actually have to type > > > > method x(Item $arg) { > > ...
> > You don't have to type that. You can type "method x($arg?)". The ? > modifier makes something optional.
Sorry, bad example on my part: take the 2 argument form, method x($arg1, $arg2) { if $arg1 is undef but $arg2 is not, we have the problem again. $arg1 cannot be specified as optional with '?' because MMS quite reasonably barfs on method x($arg1?, $arg2) { Also, method x(:$arg?) { fails when called as ->x(arg => undef); If what you want is a function that must take an argument which may be undef, you have to use 'Item' or 'Maybe'. If you want to specify a function that may accept a positional argument but that argument, if specified, must not be undef, I'm not sure you can do it at all. I believe '?' should mean strictly 'may not be present in the arg list'. 'Can legitimately be undef' is a distinct property of arguments. My preferred default - must be present, may be undef.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.