Well, it's syntactic sugar. It looks pretty alien in Smalltalk, but other languages support multiple-assignment (e.g. "swap" {a. b} := {b. a}). Of course this gets tricky because if you have multiple assignment it seems natural to return multiple values from a function (e.g. {a. b} := a swapWith: b). That would probably require a big change to implement and you end up with something Smalltalk can already do other ways, and become (more) incompatible with other dialects.> To: squeak-dev@lists.squeakfoundation.org> From: blake@kingdomrpg.com> Date: Mon, 23 Jul 2007 12:58:25 -0700> Subject: Re: Newbie question> > On Mon, 23 Jul 2007 12:27:21 -0700, subbukk subbukk@gmail.com wrote:> > > On Monday 23 July 2007 11:39 pm, Bert Freudenberg wrote:> >> >> Now, at one point the compiler even supported this:> >>> >> {a. b} := {1. 2}> >>> >> which I found cool but was considered evil, even by those who> >> tolerate the braces ...> > What would this do? It looks like you're assigning a literal to another > literal?> _________________________________________________________________ Don't get caught with egg on your face. Play Chicktionary! http://club.live.com/chicktionary.aspx?icid=chick_wlmailtextlink
On Mon, 30 Jul 2007 18:04:04 +0200, J J (in a hard-to-read HTML message :) wrote:
Well, it's syntactic sugar. It looks pretty alien in Smalltalk, but other languages support multiple-assignment (e.g. "swap" {a. b} := {b. a}). Of course this gets tricky because if you have multiple assignment it seems natural to return multiple values from a function (e.g. {a. b} := a swapWith: b). That would probably require a big change to implement and you end up with something Smalltalk can already do other ways, and become (more) incompatible with other dialects.
You can always do ^ {this. and / or. that} for returning multiple values, without any change in Squeak.
To: squeak-dev@lists.squeakfoundation.org> From: blake@kingdomrpg.com> Date: Mon, 23 Jul 2007 12:58:25 -0700> Subject: Re: Newbie question> > On Mon, 23 Jul 2007 12:27:21 -0700, subbukk subbukk@gmail.com wrote:>
On Monday 23 July 2007 11:39 pm, Bert Freudenberg wrote:> >> >> Now,
at one point the compiler even supported this:> >>> >> {a. b} := {1. 2}> >>> >> which I found cool but was considered evil, even by those who> >> tolerate the braces ...> > What would this do? It looks like you're assigning a literal to another > literal?> _________________________________________________________________ Don't get caught with egg on your face. Play Chicktionary! http://club.live.com/chicktionary.aspx?icid=chick_wlmailtextlink
On 7/30/07, Klaus D. Witzel klaus.witzel@cobss.com wrote:
On Mon, 30 Jul 2007 18:04:04 +0200, J J (in a hard-to-read HTML message :) wrote:
That would probably require a big change to implement and you end up with something Smalltalk can already do other ways, and become (more) incompatible with other dialects.
You can always do ^ {this. and / or. that} for returning multiple values, without any change in Squeak.
Yes, that's why I said "something Smalltalk can already do". But what Smalltalk couldn't do here (without modifications) is catch that return in two (or more) separate values in one line as:
|a b| {a.b} := someFunctionReturningTwoValues
On Mon, 30 Jul 2007 19:58:34 +0200, Jason Johnson wrote:
On 7/30/07, Klaus D. Witzel klaus.witzel@cobss.com wrote:
On Mon, 30 Jul 2007 18:04:04 +0200, J J (in a hard-to-read HTML message :) wrote:
That would probably require a big change to implement and you end up with something Smalltalk can already do other ways, and become (more) incompatible with other dialects.
You can always do ^ {this. and / or. that} for returning multiple values, without any change in Squeak.
Yes, that's why I said "something Smalltalk can already do". But what Smalltalk couldn't do here (without modifications) is catch that return in two (or more) separate values in one line as:
|a b| {a.b} := someFunctionReturningTwoValues
If the vars are allocated consecutively (in address space) then you must now wait for language extension to happen: ugly, but it works
| a b | a := b := 1. (1 to: 2) with: {a + 3. b + 4} do: [:ix :val | thisContext tempAt: ix put: val]. ^ {a. b}
Same for iVars, example #forceNewFrom: :| and other clients of #instVarAt:put: ...
squeak-dev@lists.squeakfoundation.org