From: Csaba Henk Date: 2005-02-19T11:34:46+09:00 Subject: Re: A Ruby-relevant quote from Alan Kay On 2005-02-18, Bill Kelly wrote: > From http://en.wikipedia.org/wiki/Smalltalk_programming_language > > One surprising feature of Smalltalk is that the traditional > progamming constructs: if-then-else, for, while, etc. are > not built into the language. All of these things are > implemented using objects. For example, decisions are made > by sending an ifTrue: message to a Boolean object, and passing > a fragment of code to execute if the Boolean is True. There > are only three built-in executable constructs: > > - sending a message to an object; > - assigning an object to a variable; > - returning an object from a method; > > and a few syntactic constructs for declaring literal objects > and temporary variables. > (Of course just prior to studying Smalltalk I had unwisely > volunteered to take over a large VB6 project... If only I'd > spent 15 minutes studying the VB6 language reference before > agreeing to that.... Gack! :) [ :) ] > >> You can define if/then/else type methods for objects with a few line of >> Ruby code easily (without using "and", "case" and any other >> conditional-like construct, of course, I mean it that way). I made it up >> to have >> >> loop { >> gets.ifthen { >> puts "you fed me a line" >> }.else { >> puts "bye"; exit >> } >> } >> >> as valid code. What is happening in the above ruby code snippet, is damn exactly the same as what you've been quoting from the Wikipedia Smalltalk article, isn't it? (OK, I used "ifthen" and not "ifTrue", but that doesn't make a difference.) Cheers, Csaba