On 06/02/2017 12:50 PM, Robert Haas wrote: > On Thu, Jun 1, 2017 at 3:36 AM, Michael Paquier >> >> + $pgnclass = 'PostgresNode' unless defined $pgnclass; >> I'd rather leave any code of this kind for the module maintainers, > > Craig's proposal is a standard Perl idiom, though.
Would it not be even more idiomatic to have the class, if present, be the first argument? That is: my $pgnclass = 'PostgresNode'; $pgnclass = shift if 1 < scalar @_; my $name = shift; That part's a little weird (an optional FIRST argument?) in order to preserve compatibility with callers who don't pass a class. But what it buys you is then if your MyExtraPGNode has PostgresNode as a base, the familiar idiom MyExtraPGNode->get_new_node('foo'); works, as it inserts the class as the first argument. As a bonus, you then don't need to complicate get_new_node with a test for (not ($node->isa("PostgresNode"))) because if it weren't, it wouldn't have inherited get_new_node so MyExtraPGNode->get_new_node('foo') would have failed. -Chap -- Sent via pgsql-hackers mailing list (firstname.lastname@example.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers