Comparison between Python and "Ruby"
bparsia at email.unc.edu
Thu Nov 4 05:26:56 CET 1999
Paul Prescod <paul at prescod.net> wrote:
> Neel Krishnaswami wrote:
> > Python (and Ruby, for that matter) remind me more of Smalltalk than
> > anything else -- ie, they have extensive libraries, a community with a
> > love of elegance but not of purity[*], and a greater focus on practical
> > applications than on academic research.
> Isn't the Smalltalk community pretty enamored of purity? I mean "if" is
> an object that takes messages, right?
> Paul Prescod
Close. Boolean's are objects which take the messages ifTrue:, ifFalse:,
ifTrue:ifFalse:, ifFalse:ifTrue:, whileTrue:, etc.
All control structures are messages (typically taking blocks--aka
anonymous functions arguments):
4 timesRepeat: [self beep]. "This is a message to an Integer."
#(1 2 3) do: [:item | Transcript cr; show: item printString].
"do: is sent to the array (the sharp parens is the literal). The block
has one parameter, internally know as 'item'). The semi-colon means to
send the next message to the same object, i.e., Transcript. Thus
Transcript gets two messages, cr and show:."
The only non-message type thing I can think of off-hand is the
assignment operator. Well, and the cascade.
More information about the Python-list