Any reason for assigning block parameter in inject:into:

Lukas Renggli renggli at gmail.com
Sun Apr 29 17:30:04 UTC 2007


> Perhaps if you think of it along the lines of:-
> a) names in a method are just local tags for programmer convenience
> so that you don't have to keep it all in your head as you read/write
> code,
> b) objects passed into the method as parameters are bound to the
> parameter tags;
> it might help.

I don't understand what you mean.

Temps and method and block arguments are all slots in some context
object. It is only the compiler that tries to stop you in an
inconsistent way from assigning to some of these slots. I initially
asked because I find that an unnecessary restriction. Usually the
philosophy of Smalltalk is to open the possibilities that the
programmer has, not to arbitrarily restrict them.

I don't say it is good style to assign to arguments. It might also
confuse beginners, I agree. I don't even suggest to change the
language. I only asked why this restriction was made in the first
place. Luckily you can always use the debugger/inspector or
thisContext tempAt:put: (there are a few methods that actually do that
in the standard image) to change these values.

Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch



More information about the Squeak-dev mailing list