Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime-Format-Strptime CPAN distribution.

Report information
The Basics
Id: 97282
Status: rejected
Priority: 0/
Queue: DateTime-Format-Strptime

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

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



Subject: constructor does not support blessed objects
$parser->new(...) gives the error: "attempt to bless into a reference" It would be helpful if the 'new' sub supported the usual convention: $my class = shift; $class = ref $class || $class;
On Wed Jul 16 11:30:14 2014, ETHER wrote: Show quoted text
> $parser->new(...) gives the error: "attempt to bless into a reference" > > It would be helpful if the 'new' sub supported the usual convention: > $my class = shift; $class = ref $class || $class;
I'm not a big fan of the $object->new. What is that supposed to mean? Is it a clone? Is it a fresh constructor? What's wrong with (ref $object)->new at the call site to make it clear that you want to do create a new object of the same class as the old?
On Wed Jul 16 18:06:17 2014, DROLSKY wrote: Show quoted text
> I'm not a big fan of the $object->new. What is that supposed to mean? > Is it a clone? Is it a fresh constructor?
Normal perl convention is for it to be equivalent to ref($object)->new IME. Show quoted text
> What's wrong with (ref $object)->new at the call site to make it clear > that you want to do create a new object of the same class as the old?
Moose tried enforcing that for a while and it turned out to be more trouble than it was worth (and remember you're hearing that from the person who came up with strictures.pm :) While, generally, I tend to write ref($object)->new myself rather than simply $object->new, the convention that they should do the same thing is pretty well established and I'd argue that you might as well DWIM.
On Thu Jul 17 12:23:54 2014, MSTROUT wrote: Show quoted text
> On Wed Jul 16 18:06:17 2014, DROLSKY wrote:
> > I'm not a big fan of the $object->new. What is that supposed to mean? > > Is it a clone? Is it a fresh constructor?
> > Normal perl convention is for it to be equivalent to ref($object)->new > IME. >
> > What's wrong with (ref $object)->new at the call site to make it > > clear > > that you want to do create a new object of the same class as the old?
> > Moose tried enforcing that for a while and it turned out to be more > trouble than it was worth (and remember you're hearing that from the > person who came up with strictures.pm :) > > While, generally, I tend to write ref($object)->new myself rather than > simply $object->new, the convention that they should do the same thing > is pretty well established and I'd argue that you might as well DWIM.
There was an effort a few (or more?) years back to rid the Perl core docs of the boilerplate that supported this idiom, and my impression is that most CPAN modules don't support this. It's possible that I'm the one who made many of the core doc changes, actually. I can't remember if this happened as part of my OO doc work or prior to it. I don't care that much one way or the other but I don't really want to spend my time going through all my non-Moose CPAN modules adding support for this either ;)