Any reason for assigning block parameter in inject:into:
Colin Putney
cputney at wiresong.ca
Sun Apr 29 20:09:56 UTC 2007
On Apr 29, 2007, at 10:03 AM, tim Rowledge wrote:
> 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.
Interesting. As far as I can tell, you're the only poster in this
thread that thinks assigning to a parameter name implies that the
parameter was passed by reference. Lukas was just complaining that
parameter slots are read-only, and giving examples of cases where it
would be nice to be able to write to them. I occasionally feel this
way too - making parameters different from other temps feels
arbitrarily inconsistent.
I wonder if this is a sign of changing times. After all,
"confusion" is a mismatch between expectations and reality. Perhaps
were seeing a change in expectations? Back in the days of yore,
people were coming to Smalltalk from low-level languages where it was
possible to pass pointers around, and returning a value through a
pass-by-reference parameter was a common idiom. These days, people
who are interested in Smalltalk are probably coming from other
dynamic languages where that's not possible, and treating parameters
as just another temp feels natural.
Personally, I think it would be nice to be able to write to parameter
slots, but it's not worth breaking compatibility with other Smalltalks.
Colin
More information about the Squeak-dev
mailing list
|