Alan Lovejoy wrote:
Link: http://i-need-closures.blogspot.com/2006/05/am-i-supposed-to-like-smalltalk. html
" Second is the 'OOP all the way' flavor of the Smalltalk language. Sometimes a function is just a function, and doesn't need to be in a class. I prefer the options that Lisp provides, I use imperative, OO, and functional, depending on the problem. "
this is now possible with LambdaMessageSend (on Squeakmap). a function can be just a function
Stef
Stéphane Rollandin wrote:
" Second is the 'OOP all the way' flavor of the Smalltalk language. Sometimes a function is just a function, and doesn't need to be in a class. I prefer the options that Lisp provides, I use imperative, OO, and functional, depending on the problem. "
this is now possible with LambdaMessageSend (on Squeakmap). a function can be just a function
Out of curiosity, can you explain to me why using:
f := Lambda x + Lambda y. f <~~ {3. 4}
would be substantially different from
f := [:x :y| x + y]. f value: 3 value: 4.
(other than that the former looks more unusual ;-) If it's about the syntax it'd be pretty simple to change the block syntax to something like here:
f(x, y) := [x + y]. f(3, 4).
[Hm ... actually this *does* look pretty reasonable; I should consider this for Croquet] I'm in particular curious about your claim this is "now" possible which seems to imply that there is something LambdaMessageSend does that blocks/closures for some reason can't represent properly.
Cheers, - Andreas
Andreas Raab wrote:
Out of curiosity, can you explain to me why using:
f := Lambda x + Lambda y. f <~~ {3. 4}
would be substantially different from
f := [:x :y| x + y]. f value: 3 value: 4.
in this precise example (with numeric arguments) the behavior is not different: actually the former uses the latest internally as its so-called "compiled form".
but now f <~~ {3 . f}
is not at all the same as the block version f value: 3 value: f (which opens the debugger)
you can check that (f <~~ {3 . f}) = (3 + (Lambda x + Lambda y)) returns true.
it also is different if you have
x := Lambda x. y := Lambda y. f := x + y. g := x * y.
because you can then directly do
(g+f) <~~ {3.4}
while with blocks you would have to do
f := [:x :y| x + y] g := [:x :y| x * y]. gplusf := [:x :y| (f value:x value: y) + (g value:x value: y)]
the printString is much clearer also:
(g+f) printString is '((<x> * <y>) + (<x> + <y>))'
while gplusf printString is '[] in UndefinedObject>>DoIt {[:x :y | (f value: x value: y) + (g value: x value: y)]}'
(I did this in a workspace)
I'm in particular curious about your claim this is "now" possible which seems to imply that there is something LambdaMessageSend does that blocks/closures for some reason can't represent properly.
in short, LambdaMessageSend implements closures out of nested MessageSends. compared to blocks it is another, completely different way to do functional programming in Smalltalk
example:
f := Lambda x + Lambda y. g := f <~~ {15 . Lambda z sqrt}.
g printString is '(15 + (<z> sqrt))' and indeed g <~ 100 return 25.0 g asBlock (compilation) returns the block [:t1 | 15 + t1 sqrt] allright
how do you do this with blocks ?
regards,
Stef
f(x, y) := [x + y]. f(3, 4).
[Hm ... actually this *does* look pretty reasonable; I should consider this for Croquet] I'm in particular curious about your claim this is "now" possible which seems to imply that there is something LambdaMessageSend does that blocks/closures for some reason can't represent properly.
Elegant, but it breaks the homogeneity of Squeak. There is no message sending in f(3, 4) Perhaps something like f@(3, 4) would make it more compliant...
Cheers, Alexandre
If you really love functions you can have one class and one method do everything! :)
Ron
-----Original Message----- From: squeak-dev-bounces@lists.squeakfoundation.org [mailto:squeak-dev- bounces@lists.squeakfoundation.org] On Behalf Of Stéphane Rollandin Sent: Wednesday, May 17, 2006 4:03 AM To: The general-purpose Squeak developers list Subject: Re: A Lisper asks, "Am I supposed to like Smalltalk?"
Alan Lovejoy wrote:
Link: http://i-need-closures.blogspot.com/2006/05/am-i-supposed-to-like-
smalltalk.
html
" Second is the 'OOP all the way' flavor of the Smalltalk language. Sometimes a function is just a function, and doesn't need to be in a class. I prefer the options that Lisp provides, I use imperative, OO, and functional, depending on the problem. "
this is now possible with LambdaMessageSend (on Squeakmap). a function can be just a function
Stef
Object>>doEverything maybe!
-----Original Message----- From: squeak-dev-bounces@lists.squeakfoundation.org [mailto:squeak-dev-bounces@lists.squeakfoundation.org]On Behalf Of Stéphane Rollandin Sent: 17 May 2006 9:01 PM To: Ron@USMedRec.com; The general-purpose Squeak developers list Subject: Re: A Lisper asks, "Am I supposed to like Smalltalk?"
Ron Teitelbaum wrote:
If you really love functions you can have one class and one method do everything! :)
hmmm... that's a puzzle ?
ok I give up ! what method ?
Stef
Stef,
You could call it method. Believe it or not I've seen people try to write smalltalk this way (100 pages of code in one method), I've also seen C++ written this way. I've asked ohh so you do C++, how many classes does your code have and they say, "what's a class!" :)
It was a bad joke!
Ron
-----Original Message----- From: Stéphane Rollandin [mailto:lecteur@zogotounga.net] Sent: Wednesday, May 17, 2006 4:01 PM To: Ron@USMedRec.com; The general-purpose Squeak developers list Subject: Re: A Lisper asks, "Am I supposed to like Smalltalk?"
Ron Teitelbaum wrote:
If you really love functions you can have one class and one method do everything! :)
hmmm... that's a puzzle ?
ok I give up ! what method ?
Stef
Stéphane Rollandin wrote:
Ron Teitelbaum wrote:
If you really love functions you can have one class and one method do everything! :)
hmmm... that's a puzzle ?
ok I give up ! what method ?
It's right there on the bottom of page 13 of the Lisp 1.5 manual.
Cheers, - Andreas
Andreas,
Ok now it's my turn to byte. So while I'm sitting here looking up the Lisp 1.5 manual I'm thinking to myself I hope this joke is better then mine. When I got there this is what I found:
evalquote is defined by using two main functions, called eval and apply. apply handles a function and its arguments, while eval handles forms. Each of these functions also has another argument that is used as an association list for storing the values of bound variables and f unction names. where apply [fn;x; a] = [atom[fn] - [ e q [ f n ; ~ ~ ~ ] - caar[x]; e q [ f n ; ~ ~ ~ ] -- cdar[x]; eq[fn; CONS] -- cons[car[x]; cadr[x]]; e q [ f n ; ~ ~ ~ ~ ] -- atom[car[x]]; eq[fn; EQ] - eq[car[x]; cadr[x]]; T - apply[eval[fn;a];x;a]]; eq[car[fn]; LAMBDA] -- eval[caddr [fn]; pairlis[cadr[fn];x;a]]; eq[car [fn]; LABEL] - apply [caddr [fn]; x; cons [cons[cadr [fn]; c addr [f n]]; a]]] eval[e;a] = [atom[e] - cdr[assoc[e;a]]; atom[car[e]] - [eq[car QUOTE] - cadr [el; eq[car[e]; COND] - evcon[cdr [el; a]; T -- apply[car [el; evlis[cdr [el; a]; a]]; T - apply[car [el; evlis [cdr [el; a]; a]] pairlis and assoc have been previously defined. evcon[c; a] = [eval[caar [c]; a] -- eval[cadar [c]; a]; T -- evcon[cdr [c];a]] and evlis[m;a] = [null[m] - NIL; T - cons [eval[car [m];a];evlis[cdr [m];a]]]
So other then an offhanded joke about Elvis I have to admit I don't get it!
:^D
Ron
-----Original Message----- From: squeak-dev-bounces@lists.squeakfoundation.org [mailto:squeak-dev- bounces@lists.squeakfoundation.org] On Behalf Of Andreas Raab Sent: Wednesday, May 17, 2006 5:25 PM To: The general-purpose Squeak developers list Subject: Re: A Lisper asks, "Am I supposed to like Smalltalk?"
Stéphane Rollandin wrote:
Ron Teitelbaum wrote:
If you really love functions you can have one class and one method do everything! :)
hmmm... that's a puzzle ?
ok I give up ! what method ?
It's right there on the bottom of page 13 of the Lisp 1.5 manual.
Cheers,
- Andreas
Well, this function actually defines all of LISP, so literally, this is "one function to do everything". It's a kernel even smaller than Smalltalk's (and preceding it by decades).
- Bert -
Am 18.05.2006 um 01:48 schrieb Ron Teitelbaum:
Andreas,
Ok now it's my turn to byte. So while I'm sitting here looking up the Lisp 1.5 manual I'm thinking to myself I hope this joke is better then mine. When I got there this is what I found:
evalquote is defined by using two main functions, called eval and apply. apply handles a function and its arguments, while eval handles forms. Each of these functions also has another argument that is used as an association list for storing the values of bound variables and f unction names. where apply [fn;x; a] = [atom[fn] - [ e q [ f n ; ~ ~ ~ ] - caar[x]; e q [ f n ; ~ ~ ~ ] -- cdar[x]; eq[fn; CONS] -- cons[car[x]; cadr[x]]; e q [ f n ; ~ ~ ~ ~ ] -- atom[car[x]]; eq[fn; EQ] - eq[car[x]; cadr[x]]; T - apply[eval[fn;a];x;a]]; eq[car[fn]; LAMBDA] -- eval[caddr [fn]; pairlis[cadr[fn];x;a]]; eq[car [fn]; LABEL] - apply [caddr [fn]; x; cons [cons[cadr [fn]; c addr [f n]]; a]]] eval[e;a] = [atom[e] - cdr[assoc[e;a]]; atom[car[e]] - [eq[car QUOTE] - cadr [el; eq[car[e]; COND] - evcon[cdr [el; a]; T -- apply[car [el; evlis[cdr [el; a]; a]]; T - apply[car [el; evlis [cdr [el; a]; a]] pairlis and assoc have been previously defined. evcon[c; a] = [eval[caar [c]; a] -- eval[cadar [c]; a]; T -- evcon[cdr [c];a]] and evlis[m;a] = [null[m] - NIL; T - cons [eval[car [m];a];evlis[cdr [m];a]]]
So other then an offhanded joke about Elvis I have to admit I don't get it!
:^D
Ron
-----Original Message----- From: squeak-dev-bounces@lists.squeakfoundation.org [mailto:squeak- dev- bounces@lists.squeakfoundation.org] On Behalf Of Andreas Raab Sent: Wednesday, May 17, 2006 5:25 PM To: The general-purpose Squeak developers list Subject: Re: A Lisper asks, "Am I supposed to like Smalltalk?"
Stéphane Rollandin wrote:
Ron Teitelbaum wrote:
If you really love functions you can have one class and one method do everything! :)
hmmm... that's a puzzle ?
ok I give up ! what method ?
It's right there on the bottom of page 13 of the Lisp 1.5 manual.
Cheers,
- Andreas
Thanks Bert!
Ron
-----Original Message----- From: Bert Freudenberg [mailto:bert@impara.de] Sent: Thursday, May 18, 2006 4:09 PM To: The general-purpose Squeak developers list Cc: Ron@USMedRec.com Subject: Re: A Lisper asks, "Am I supposed to like Smalltalk?"
Well, this function actually defines all of LISP, so literally, this is "one function to do everything". It's a kernel even smaller than Smalltalk's (and preceding it by decades).
- Bert -
Am 18.05.2006 um 01:48 schrieb Ron Teitelbaum:
Andreas,
Ok now it's my turn to byte. So while I'm sitting here looking up the Lisp 1.5 manual I'm thinking to myself I hope this joke is better then mine. When I got there this is what I found:
evalquote is defined by using two main functions, called eval and apply. apply handles a function and its arguments, while eval handles forms. Each of these functions also has another argument that is used as an association list for storing the values of bound variables and f unction names. where apply [fn;x; a] = [atom[fn] - [ e q [ f n ; ~ ~ ~ ] - caar[x]; e q [ f n ; ~ ~ ~ ] -- cdar[x]; eq[fn; CONS] -- cons[car[x]; cadr[x]]; e q [ f n ; ~ ~ ~ ~ ] -- atom[car[x]]; eq[fn; EQ] - eq[car[x]; cadr[x]]; T - apply[eval[fn;a];x;a]]; eq[car[fn]; LAMBDA] -- eval[caddr [fn]; pairlis[cadr[fn];x;a]]; eq[car [fn]; LABEL] - apply [caddr [fn]; x; cons [cons[cadr [fn]; c addr [f n]]; a]]] eval[e;a] = [atom[e] - cdr[assoc[e;a]]; atom[car[e]] - [eq[car QUOTE] - cadr [el; eq[car[e]; COND] - evcon[cdr [el; a]; T -- apply[car [el; evlis[cdr [el; a]; a]]; T - apply[car [el; evlis [cdr [el; a]; a]] pairlis and assoc have been previously defined. evcon[c; a] = [eval[caar [c]; a] -- eval[cadar [c]; a]; T -- evcon[cdr [c];a]] and evlis[m;a] = [null[m] - NIL; T - cons [eval[car [m];a];evlis[cdr [m];a]]]
So other then an offhanded joke about Elvis I have to admit I don't get it!
:^D
Ron
-----Original Message----- From: squeak-dev-bounces@lists.squeakfoundation.org [mailto:squeak- dev- bounces@lists.squeakfoundation.org] On Behalf Of Andreas Raab Sent: Wednesday, May 17, 2006 5:25 PM To: The general-purpose Squeak developers list Subject: Re: A Lisper asks, "Am I supposed to like Smalltalk?"
Stéphane Rollandin wrote:
Ron Teitelbaum wrote:
If you really love functions you can have one class and one method do everything! :)
hmmm... that's a puzzle ?
ok I give up ! what method ?
It's right there on the bottom of page 13 of the Lisp 1.5 manual.
Cheers,
- Andreas
On 18-May-06, at 1:08 PM, Bert Freudenberg wrote:
Well, this function actually defines all of LISP, so literally, this is "one function to do everything". It's a kernel even smaller than Smalltalk's (and preceding it by decades).
It's also a startling example of the wisdom of the old saying "simplify as much as possible - and no further".
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Strange OpCodes: SDR: Shift Disk Right
squeak-dev@lists.squeakfoundation.org