FINALLY: Another language adopts Smalltalk's keyword -syntax - Smalltalk
This is a discussion on FINALLY: Another language adopts Smalltalk's keyword -syntax - Smalltalk ; Well, not literally, but similarly.
In Groovy 1.5 you can write code like:
monster.move left: 3.meters, at: 5.mph
In Smalltalk the above would read:
monster moveLeft: 3 meters at: 5 mph
I think: Again, another try at striving
towards Smalltalk's ...
-
FINALLY: Another language adopts Smalltalk's keyword -syntax
Well, not literally, but similarly.
In Groovy 1.5 you can write code like:
monster.move left: 3.meters, at: 5.mph
In Smalltalk the above would read:
monster moveLeft: 3 meters at: 5 mph
I think: Again, another try at striving
towards Smalltalk's eloquence, yet still
not quite getting there.
More about Groovy 1.5 is at
http://www.infoq.com/articles/groovy...634CEC584E8E04
-Panu Viljamaa
-
Re: FINALLY: Another language adopts Smalltalk's keyword -syntax
Panu wrote:
> Well, not literally, but similarly.
> In Groovy 1.5 you can write code like:
> monster.move left: 3.meters, at: 5.mph
> In Smalltalk the above would read:
> monster moveLeft: 3 meters at: 5 mph
> I think: Again, another try at striving
> towards Smalltalk's eloquence, yet still
> not quite getting there.
And what if I want to write :
monster at: 5 mph moveLeft: 3 meters
Cannot do that in Smalltalk. Hmm.
A better title might be :
FINALLY: Another language on the road to Lisp/CLOS keyword parameter
schemes ...
Regards,
Steven Perryman
-
Re: FINALLY: Another language adopts Smalltalk's keyword -syntax
S Perryman wrote:
> And what if I want to write :
>
> monster at: 5 mph moveLeft: 3 meters
>
> Cannot do that in Smalltalk. Hmm.
Hmm? The above seems like valid Smalltalk to me.
Just like:
myDictionary at: 5 someMsg put: 3 someOtherMsg
I haven't done Lisp in years, but isn't it also the
case that you would need to add some parenthesis
to make your example an executable snippet of Lisp?
-Panu Viljamaa
-
Re: FINALLY: Another language adopts Smalltalk's keyword -syntax
On Sun, 16 Dec 2007 06:12:58 -0500
Panu <panu@nospam.com> wrote:
> S Perryman wrote:
> > And what if I want to write :
> >
> > monster at: 5 mph moveLeft: 3 meters
> >
> > Cannot do that in Smalltalk. Hmm.
>
> Hmm? The above seems like valid Smalltalk to me.
> Just like:
>
> myDictionary at: 5 someMsg put: 3 someOtherMsg
>
>
> I haven't done Lisp in years, but isn't it also the
> case that you would need to add some parenthesis
> to make your example an executable snippet of Lisp?
>
> -Panu Viljamaa
>
$ sbcl
....
* (defun monster (&key at moveLeft) (list at moveLeft))
MONSTER
* (monster :at 5 :moveLeft 10)
(5 10)
* (monster :moveLeft 10 :at 5)
(5 10)
One of Lisp's advantages is that the sequence of keyword arguments does
not matter. And you could define default values so that you would not
have to provide all arguments all the time. And this works with a single
function definition, whereas in Smalltalk I'd have to define multiple
methods for the different ways of calling it.
s.
-
Re: FINALLY: Another language adopts Smalltalk's keyword -syntax
Stefan Schmiedl <s@xss.de> wrote:
> One of Lisp's advantages is that the sequence of keyword arguments does
> not matter.
You are assuming that is an advantage...
monster moveAt: 5 mph left: 3 meters.
monster moveLeft: 3 meters at: 5 mph.
It seems to me that allowing both lines above obfuscates without adding
anything useful.
-
Re: FINALLY: Another language adopts Smalltalk's keyword -syntax
Panu <panu@nospam.com> writes:
>In Groovy 1.5 you can write code like:
>monster.move left: 3.meters, at: 5.mph
A common beginner's language such as
Microsoft®'s Visual Basic for Applications
allows it.
? DateAdd( Date := "31-Jan-95", Number := 1, Interval := "m" )
28.02.95
? DateAdd( Number := 1, Interval := "m", Date := "31-Jan-95" )
28.02.95
Commands use it:
process -s from.txt -t to.txt
reading from "from.txt", writing to "to.txt".
process -t to.txt -s from.txt
reading from "from.txt", writing to "to.txt".
It always was a common choice in language design.
-
Re: FINALLY: Another language adopts Smalltalk's keyword -syntax
On Sun, 16 Dec 2007 13:42:46 -0500
"Daniel T." <daniel_t@earthlink.net> wrote:
> Stefan Schmiedl <s@xss.de> wrote:
>
> > One of Lisp's advantages is that the sequence of keyword arguments does
> > not matter.
>
> You are assuming that is an advantage...
I *know* that it has been an advantage for me since I had less to
remember: only the names instead of names+sequence.
s.
-
Re: FINALLY: Another language adopts Smalltalk's keyword -syntax
Stefan Schmiedl <s@xss.de> wrote:
> "Daniel T." <daniel_t@earthlink.net> wrote:
> > Stefan Schmiedl <s@xss.de> wrote:
> >
> > > One of Lisp's advantages is that the sequence of keyword
> > > arguments does not matter.
> >
> > You are assuming that is an advantage...
>
> I *know* that it has been an advantage for me since I had less to
> remember: only the names instead of names+sequence.
You anecdotal evidence is hardly convincing.
-
Re: FINALLY: Another language adopts Smalltalk's keyword -syntax
"Daniel T." <daniel_t@earthlink.net> wrote in message
news:daniel_t-439404.10541217122007@earthlink.vsrv-sjc.supernews.net...
> Stefan Schmiedl <s@xss.de> wrote:
SS> One of Lisp's advantages is that the sequence of SS>keyword arguments
does not matter.
DT> You are assuming that is an advantage...
>> I *know* that it has been an advantage for me since I
>> had less to remember: only the names instead of
>> names+sequence.
> You anecdotal evidence is hardly convincing.
Anecdotal +1 ( 1. same reasons as Stefan. 2. have programmed
in industry in both CLOS and Smalltalk) .
Regards,
Steven Perryman
-
Re: FINALLY: Another language adopts Smalltalk's keyword -syntax
Hi Cesar,
On Mon, 17 Dec 2007 18:19:31 -0300
Cesar Rabak <csrabak@yahoo.com.br> wrote:
> S Perryman escreveu:
> > "Daniel T." <daniel_t@earthlink.net> wrote in message
> > news:daniel_t-439404.10541217122007@earthlink.vsrv-sjc.supernews.net...
> >
> >> Stefan Schmiedl <s@xss.de> wrote:
> >
> > SS> One of Lisp's advantages is that the sequence of SS>keyword arguments
> > does not matter.
> >
> > DT> You are assuming that is an advantage...
> >
> >>> I *know* that it has been an advantage for me since I
> >>> had less to remember: only the names instead of
> >>> names+sequence.
> >
> >> You anecdotal evidence is hardly convincing.
It does not have to *convince* anybody, I'm only pointing out that
I'm not *assuming*, but instead *know*.
> In Smalltalk:
> monster moveLeft: 3 meters at: 5 mph.
>
> In CLOS:
>
> (monster :moveLeft 10 :at 5)
>
> This CLOS variant:
>
> (monster :at 5 :moveLeft 10)
>
> isn't it a way of writting in Smalltalk again:
> monster at: 5 mph; moveLeft: 3 meters.
Yes. Cascading goes a long way towards avoiding combinatorial
explosions. How does it fare with providing default arguments?
(defun move-monster-left (monster &key (distance 10) (speed 5))
(list distance speed))
can be called as
(move-monster-left m) -> (10 5)
(move-monster-left m :distance 20) -> (20 5)
(move-monster-left m :speed 7) -> (10 7)
(move-monster-left m :speed 7 :distance 20) -> (20 7)
How would this translate to idiomatic Smalltalk?
Dang... switched into Lisp mode now, can't think smalltalky anymore.
s.
Similar Threads
-
By Application Development in forum Object
Replies: 45
Last Post: 02-01-2008, 12:51 AM
-
By Application Development in forum ADA
Replies: 6
Last Post: 08-10-2007, 09:08 PM
-
By Application Development in forum ADA
Replies: 0
Last Post: 08-08-2007, 03:02 PM
-
By Application Development in forum Python
Replies: 4
Last Post: 07-26-2007, 12:50 AM
-
By Application Development in forum Java
Replies: 0
Last Post: 05-17-2007, 03:49 PM