Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

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


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

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.


Comment on Re^3: (Sort of) poll: what Perl6 features do you consider {likely,desirable} to leak into P5?
Select or Download Code
Re^4: (Sort of) poll: what Perl6 features do you consider {likely,desirable} to leak into P5?
by TheDamian (Priest) on Mar 09, 2005 at 20:42 UTC
    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...

    ;-)

      This node was taken out by the NodeReaper on Thu Mar 10 00:22:11 2005 (EST)
      Reason: [BrowserUk]: Duplicate

      For more information on this node visit: this

      Unfortunately, Perl 5's import and subroutine prototype mechanisms aren't quite up to the task ...

      I wasn't critiquing your implementation of Perl6::Say, just the useability.

      As you say, it's just one of those features that you cannot adaquately emulate at the Perl level. I'm having a go at trying my PP_say() wrapper around pp_print() in pp_hot.c--but it segfaults with my first attempt (and second:().


      Examine what is said, not who speaks.
      Silence betokens consent.
      Love the truth but pardon error.
      I agree. And it's probably not going to be a hard patch. But there will be the backwards compatability police - as adding 'say' as a keyword might possibly break existing code.

      * grepping old sources *

      Funny. Seems it might "break" one module I made a long, long time ago:

      sub say { print(STDOUT @_); if ($_[$#_] !~ /\n$/) { print(STDOUT "\n"); } }
      As far as I can tell, it was written in 1997 or 1998. I can live with that breaking (it seems to be doing something similar to Perl6::Say anyway - although I can't tell anymore whether adding the newline, or the printing to STDOUT was the main feature for it). But, if proposed, someone is bound to make the unsupported claim that "thousands and thousands of programs will be broken".

      Hmmm, looking at the code I digged up I can see the charm of a print function that adds a newline only if the string to print doesn't end with a newline. Kind of like chomp only chopping of newlines.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-12-25 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (159 votes), past polls