[Newbies] Re: Modify block (closure) parameters
Yoshiki.Ohshima at acm.org
Wed Aug 7 23:35:07 UTC 2013
At Wed, 07 Aug 2013 15:05:56 -0700,
Edwin Castro wrote:
> On 8/7/13 12:33 PM, Levente Uzonyi wrote:
> > On Wed, 7 Aug 2013, psea wrote:
> >> 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
> > Smalltalk code.
> Why is storing into a block or method argument considered bad practice?
> Better performance seems like a good reason to follow the practice. I
> must assume there are dangers, non-obvious to beginners like me, which
> causes the practice to become bad. Of course, one reason is that Squeak
> doesn't properly support it today but as mentioned earlier other ST
> systems support the practice so I'm curious what causes it to be
> considered bad.
One reason is that it would prevent the edit and restart debug session
from being effective. If some arguments are rewritten by the time
you decided to restart the context, you don't get a repeatable result.
The above being one reason, the overall design that any program should
aspire to was to make functions/methods/blocks pure froms side-effects
whenever possible, and actions/side-effecting part isolated. Dan and
Alan both have written and talked about that idea.
More information about the Beginners