[squeak-dev] Multiple assignment / arguments (was: what is smalltalk?)

Bert Freudenberg bert at freudenbergs.de
Thu Feb 13 10:18:34 UTC 2014


On 13.02.2014, at 00:05, Tobias Pape <Das.Linux at gmx.de> wrote:

> On 12.02.2014, at 23:49, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> 
>> It's nicer to be able to write
>> 
>> 	roots, accessors, assignments :=
>> 		self accessorsAndAssignmentsForMethod: method
>> 			actuals: {}
>> 			depth: 0
>> 			interpreterClass: interpreterClass
> 
> There used to be a syntax like this:
> 
> 	{ roots . accessors . assignments } := #( 1 2 3 )
> 
> But, while there are traces of support for that, I seems largely ripped out… (to my sad-face-ing)
> 
>>> A pet hack
>>> I've been working on has a #destructureIn: where you can say
>>> 
>>> #(1 2) destructureIn: [:x :y | x + 1]
>>> 
>>> which lets me avoid loads of local variables.
>>> 
>> Yes, I use something similar a fair bit
>> 
>>    [:a :b ... | ... ] valueWithArguments: tuple
>> 
>> etc.

So there's two desires here: (1) assigning to multiple variables at once, and (2) avoiding declaring variables. 

For (1) we do need new syntax (or revive old syntax). For (2) we have #in: for a single value and #valueWithArguments: for multiple values, although the order is counter-intuitive.

So maybe we could add an #allIn: (or another selector if there is precedence in other dialects)?

For the multiple assignment syntax I don't remember what the actual problem was. Decompiler support maybe?

- Bert -


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4142 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140213/652e42b9/smime.bin


More information about the Squeak-dev mailing list