Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^6: perl 5.12 BSD portability (CPAN test result)...print

by perl-diddler (Hermit)
on Mar 15, 2013 at 21:29 UTC ( #1023781=note: print w/ replies, xml ) Need Help??


in reply to Re^5: perl 5.12 BSD portability (CPAN test result)...print
in thread perl 5.12 BSD portability (CPAN test result)...print

Ah...I thought it was just an indirect method call...didn't know it was it's own special operator... Does it still have to be it's own special operator? I.e. are there places where the indirect method call wouldn't give the same behavior? (Apparently there were in the past, but what about now?)....


Comment on Re^6: perl 5.12 BSD portability (CPAN test result)...print
Re^7: perl 5.12 BSD portability (CPAN test result)...print
by ikegami (Pope) on Mar 16, 2013 at 18:35 UTC

    Assuming you're ok with breaking every program that does print $x, how would you implement IO::Handle::print without the print operator?

    There are other issues, but they're not worth mentioning after the above two.

      Um, I suppose I'm not sure I see the difference between a method called print, called indirectly, that appears to do the same thing as C<print> the operator.

      Could you explain the difference to someone to whom it is not obvious? ;-)

        Without an explicit filehandle, where does the output of print $x go? How is Perl to tell the difference between "print the contents of $_ to the filehandle in $x" from "print the contents of $x to the currently selected filehandle"?

        So you want me to explains how it's impossible to write the method without the print operator? Well, why don't you try it.

        Or are you asking me to explain why they don't do the same thing? Well, consider

        >perl -le"$x = 'abc'; print $x;" abc

        As you can see, it doesn't call the method $x of class abc. If it was an indirect method call, it would have the following outcome:

        >perl -le"$x = 'abc'; $x->print;" Can't locate object method "print" via package "abc" (perhaps you forg +ot to load "abc"?) at -e line 1.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-12-23 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (135 votes), past polls