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

Re^2: RFC: Simulating Ruby's "yield" and "blocks" in Perl

by LanX (Canon)
on Apr 22, 2013 at 17:12 UTC ( #1029931=note: print w/ replies, xml ) Need Help??


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

> (on the interpreter-level - not via (sorry) ugly hacks like your "yield").

Backwards compatibility is always an issue when discussing new features.

Ugly hacks which work (even slowly) for old Perl versions improve the acceptance of new features.

And normally the "ugliness" would be hidden in a module, much like the code of the Perl interpreter isn't judged for prettiness.

update

> Are languages like Perl, Python, Ruby, Javascript not all "essentially" the same?

Nope!

Just to make it measurable:

The efforts needed for an experienced Perl programmer to learn Python are at least 10 times bigger than for Ruby.

It's because Ruby copied semantics and even names for operators and idioms deep into details. Old docs for Ruby still mentioned the strong Perl heritage.

And you might notice that a "ruby" is a gem and not a snake.

AFAIK the semantic influence of Python is basically the exception system.

update

To give a concrete example, the equivalent for an anonymous sub in Perl or a {block} in Ruby is a lamda in Python. But a lamda is restricted to at most one statement, with the effect that some functional idioms in Python look like a cluttered mess of nested lambdas.

update

Furthermore Python doesn't have variable interpolation in strings, you must use printf or similar replacement techniques.

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re^2: RFC: Simulating Ruby's "yield" and "blocks" in Perl
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-10-23 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (129 votes), past polls