Masklinn a écrit :
On 31 Jul 2009, at 13:38 , Bruno Desthuilliers wrote:
Steven D'Aprano a écrit :
On Thu, 30 Jul 2009 18:47:04 +0100, Tim Rowe wrote:
That and the fact that I couldn't stop laughing for long enough to learn
any more when I read in the Pragmatic Programmer's Guide that "Ruby,
unlike less flexible languages, lets you alter the value of a constant."
Yep, as they say "Bug" = "Undocumented feature"!
That's no different from Python's "constant by convention".
Ruby's code blocks come from Smalltalk, where they are an absolute necessity since message passing (which code blocks are part of) is the *only* builtin control flow in Smalltalk - so you just *need* this construction to provide branching and iterations.

I'm not so sure about the way you say it.

I'm not sure about the way you understand it !-)

I'm pretty sure "traditional" flow control structures preceded Smalltalk by a pair of decades

Yes, of course - and that's not the point. What's important is that:


so it's not that Smalltalk's designers found it necessary to use blocks & messages, but that they understood blocks & messages could trivially replace most control structures (making *those* unnecessary), making the core language simpler and more flexible.

Exactly.

In other words, I see it the other way around.

My wording may have been a bit confusing, indeed. It was implied (but perhaps a bit unclear) that restricting control structures to messages and blocks was a design choice.

Wether it makes sense to have code blocks in Ruby is another question since Ruby does provide traditional control flow features
>
Well it does at least allow for the creation of new flow control structures in library land when the existing ones aren't enough (e.g. allows Ruby not to require the introduction of a `with` statement).

Yeps. But then other "traditionnal" control flow features become redundant.

Though Ruby's blocks are nowhere near as flexible as Smalltalk's.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to