[squeak-dev] Re: [Newbies] Re: Modify block (closure) parameters
leves at elte.hu
Wed Aug 7 19:33:04 UTC 2013
On Wed, 7 Aug 2013, psea wrote:
> Ok, i've got it. So in ST it's just not allowed assign to a block argument
> for some reason. Let's consider it a language feature. And it's ok,
It's a compiler bug. The compiler doesn't handle this case.
- TempVariableNode >> #analyseClosure: returns if the receiver is a block
argument without checking the preference.
- BlockNode >> #postNumberingProcessTempsWithin:rootNode: only checks the
temporaries, but not the arguments of the receiver.
- Even if the above two are fixed, the temp index is still out of bounds,
because removing arguments is not supported (see
#removeTempNode:ifAbsent: and its sender), so the original temp for the
argument will be kept.
> different language - different rules. Thanks for pointing me on that!
> Now, I've turn off allowBlockArgumentAssignment property.
> What's worried me is that in other languages I'm familiar with it's a normal
Storing into a block or method argument is considered bad practice.
Support for it is/was planned to be removed. Even though it can yield
somewhat better performance, it's something you'll rarely see in
> answer to your questions:
> Smalltalk vmVersion 'Squeak3.10.2 of 11 February 2010 [latest update:
> SmalltalkImage current systemInformationString "ditto" 'Squeak4.3
> latest update: #11860
> Current Change Set: Unnamed1'
> Windows XP.
> PS But you should agree with me that
> makeAcc := [ :acc |
> [:n | acc:=acc+n. acc]]
> looks a little bit better and concise than
> makeAcc := [ :acc |
> | total |
> [:n | total:=total+n. total]]
There's no need to explicitly return 'total' from the inner block, because
the assignment yields the same value:
makeAcc := [ :acc |
| total |
total := acc.
[ :n | total := total + n ] ]
> And thanks for the links.
> View this message in context: http://forum.world.st/Modify-block-closure-parameters-tp4702118p4702410.html
> Sent from the Squeak - Beginners mailing list archive at Nabble.com.
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
More information about the Squeak-dev