Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: (Sort of) poll: what Perl6 features do you consider {likely,desirable} to leak into P5?

by BrowserUk (Pope)
on Mar 09, 2005 at 18:13 UTC ( #437990=note: print w/ replies, xml ) Need Help??


in reply to (Sort of) poll: what Perl6 features do you consider {likely,desirable} to leak into P5?

The say command.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.


Comment on Re: (Sort of) poll: what Perl6 features do you consider {likely,desirable} to leak into P5?
Select or Download Code
Re^2: (Sort of) poll: what Perl6 features do you consider {likely,desirable} to leak into P5?
by Juerd (Abbot) on Mar 09, 2005 at 19:27 UTC

    package Perl6::say; use base 'Exporter'; @EXPORT = 'say'; sub say { print @_, "\n"; } 1 __END__ =head1 NAME Perl6::say - Perl extension to get say in Perl 5 =head1 DESCRIPTION DWYM :) =head2 Exported list operators =head3 say C<print>s its arguments and "\n"; =head1 CAVEATS Does not support printing to filehandles that are not currently C<sele +ct>ed (one arg). =head1 SEE ALSO L<perlfunc/print>

    :)

      I've tried Perl6::Say, but found it wanting.

      The list of caveats regarding the type of filehandles it will work with is annoying. I tend to store file handles in hash elements quite frequently, and use indirect object notation print { $fhs{INPUT} } $stuff;, and that doesn't work with P6::Say.

      I'm not ready to give up the simplicity of that notation and move to $fhs{INPUT}->say ... . If filehandles were truely OO constructs, complete with independant settings for $/, $\, $=, $., $^ etc. etc., then it would be a different matter...but they aren't.

      If say were implemented within the language, it would be barely any code at all. Just a stub sub, pp_say, that localised $\ and set it to "\n", and then calls pp_print() would probably be all was required, but it would 'Just work'.

      I think it would be a very useful addition to Perl5--but then I'm biased against having to add zillions of ."\n"s :)


      Examine what is said, not who speaks.
      Silence betokens consent.
      Love the truth but pardon error.
        I'd definitely like to see say in Perl 5. After the // operator (which is already slated for 5.10), I think say is probably the biggest "bang-for-the-buck" in all of Perl 6.

        As for Perl6::Say being "wanting", I would agree. Unfortunately, Perl 5's import and subroutine prototype mechanisms aren't quite up to the task of implementing a full print-like syntax. If only I could do it in Perl 6. Oh, wait...

        ;-)

Re^2: (Sort of) poll: what Perl6 features do you consider {likely,desirable} to leak into P5?
by dragonchild (Archbishop) on Mar 09, 2005 at 20:58 UTC
    Isn't say just as simple as adding 'say' as a keyword to keywords.pl in the Perl source, recompiling, then doing:
    *CORE::GLOBAL::say = sub { print @_, $/ };

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      Not quite. For a start, $/ may not be set, or could be set to \42 or ...


      Examine what is said, not who speaks.
      Silence betokens consent.
      Love the truth but pardon error.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2014-07-29 19:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (226 votes), past polls