Any reason for assigning block parameter in inject:into:

tim Rowledge tim at rowledge.org
Sun Apr 29 17:03:43 UTC 2007


On 29-Apr-07, at 9:17 AM, Keith Hodges wrote:

>
> What you are saying is that the named parameter that comes into the  
> method which looks like a variable, and you use it like a variable  
> is actually a constant within the context of that method. Its  
> actually counter intuitive.

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.

Assigning some new object to the tag used for a parameter is  
confusing and pointless because it can have no effect outside the  
local context despite *looking like* it might replace the object to  
someone not familiar. To prevent that confusion, the compiler  
prevents the assignment.


tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
"Wibble" said Pooh the stress beginning to show.





More information about the Squeak-dev mailing list