Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

For gawds sake why would I want to do anything that silly, replacing something readable with the use of an ill-designed and ill-named nonsense? Yieiaild? There's nothing in the dictionary that would match the way this keyword is used in Ruby. Yeah, yield as a keyword related to coroutines, fine. You yield the execution and let someone outside the subroutine decide when to continue, but that's not what it means in Ruby!

sub test (&){ my $print = shift; say "You are in the method"; $print->(1); say "You are again back to the method"; $print->(2); } test { say "You are in the block $_[0]" };

is not only more readable, but also more extensible! You are not restricted to a single "callback" and if you need to pass the subroutine reference/closure/block (I know the differences, thank you very much) somewhere else you can! Try that in Ruby!

BTW, does the |a,b| finally declare new variables in Ruby or does it still reuse the a and b if they happen to be defined? Yeah, I know, a method in Ruby should not take more than four lines ... it doesn't matter you end up having hundreds of them.

Enoch was right!
Enjoy the last years of Rome.

In reply to Re: RFC: Simulating Ruby's "yield" and "blocks" in Perl by Jenda
in thread RFC: Simulating Ruby's "yield" and "blocks" in Perl by LanX

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2022-10-07 09:17 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (29 votes). Check out past polls.