[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accumulator



On Thu, 23 May 2002, Paul Prescod wrote:

> Inner functions have less restrictions than lambda, but the particular
> restriction about overwriting variables from outer scopes is still in
> effect. I still maintain that this encourages a better (OO, in an OO
> programming language) style of programming.

What I find interesting about this actually has nothing to do with better
OO style, particularly since the vast majority of OO languages don't
support named inner functions; rather, it has to do with good functional
style.  As you point out in a different reply, mutable bindings encourage
side effects - in a language without (let ()), maybe it is indeed a good
thing to have side-effect free lambdas.  From my web-centric point of
view: backtracking works a lot better when you keep mutation to a
minimum.

Of course, I'd still rather have the flexibility to create a new binding
or capture an existing one as I choose - and in a language where shadowing
an existing binding is impossible (ie, Ruby), you can always work around
the issue by picking a new name.  But if you're trying to encourage a
functional style, I can indeed see the logic behind restricting mutation.