Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^5: RFC: Integer::Partition::Unrestricted

by brian_d_foy (Abbot)
on Feb 28, 2006 at 17:25 UTC ( [id://533425]=note: print w/replies, xml ) Need Help??


in reply to Re^4: RFC: Integer::Partition::Unrestricted
in thread RFC: Integer::Partition::Unrestricted

What happens when you want to use the real pos()? I'm not worried about the methods. I'm talking about using the builtins, which you don't call as methods. :)

Update: You have to be able to explain to everyone else who looks at your code why Perl ignores the subroutine you defined, which one you really wanted, and all sorts of other things. pos() may not be the best example though.

#!/usr/bin/perl use warnings; sub shift { } my @array = qw( 1 2 3 ); shift @array;

In general, don't purposedly cause ambiguity.

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review

Replies are listed 'Best First'.
Re^6: RFC: Integer::Partition::Unrestricted
by adrianh (Chancellor) on Feb 28, 2006 at 17:47 UTC
    What happens when you want to use the real pos()? I'm not worried about the methods. I'm talking about using the builtins, which you don't call as methods. :)

    ?

    use strict; use warnings; { package Foo; sub pos { "pos" } sub bar { my $foo = "xxx"; $foo =~ m/x/g; return pos $foo; }; }; use Test::More 'no_plan'; is( Foo->pos, "pos", "we can call Foo's pos method" ); is( Foo->bar, 1, "and still use pos inside the package" );

      That’s exactly the point: there’s a call to pos, but it invokes pos, not your sub pos. That call to pos is ambiguous to the reader.

      I agree with brian on this one.

      Makeshifts last the longest.

        That’s exactly the point: there’s a call to pos, but it invokes pos, not your sub pos. That call to pos is ambiguous to the reader.

        That argument I can accept (if not agree with), but I didn't get that from the post before the update :-)

        Personally I don't find it an ambiguous read. I'm pretty religious about not using () for keywords, and not using prototypes for functions so the fact that it's pos $foo rather than pos( $foo ) is already telling me that it's a keyword not a subroutine call. Combine that with knowing how perl treats clashes between subroutines and keywords and I know that it's not going to cause problems.

        However I can see that it's an issue that reasonable people can differ over.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://533425]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-24 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found