Misunderstanding about closures

Alexander Schmolck a.schmolck at gmx.net
Wed Jun 16 19:03:55 CEST 2004


Jacek Generowicz <jacek.generowicz at cern.ch> writes:

> Alexander Schmolck <a.schmolck at gmx.net> writes:
>
>> you seem to imply that somehow scheme does something inappropriate
>
> No, that's what you inferred;

Hence "seem to". 

> I never intended to imply any such thing.

Great, but I thought that your post might give people the wrong idea and
that's why I wanted to clarify things a bit.

> I merely pointed out the facts:
>
> - Scheme iteration is recursion based
>
> - Scheme lexical scoping is not significantly different from Python's;
>   the apparent differences can be explained by the above.

Since I neither claimed that scheme iteration is not recursion based nor that
lexical scoping from scheme is in any way different from python's you might in
fact have followed up to my post for a similar reason.

This dredging up of former quotes is generally a bad thing to do, but I'll do
it anyway in the hope to lay the whole thing to rest.

> Alexander Schmolck <a.schmolck at gmx.net> writes:
>> [in] scheme, the standard iteration construct 'do' does indeed introduce
>> a *new binding* on each iteration.

> Yes, but this is a consequence of Scheme faking iteration with
> recursion.

Not really. Also, faking X with Y is usually taken to imply that X is inferior
to Y (in general or at least in some specific capacity).

This is not the case here, in fact the behavior you can achieve with scheme's
recursion is a strict superset of what can be achieved with CL's and python's
iteration. Also, notably, the converse is not the case.

> Unfortunately, I don't think that it's so easy (or even possible?) to
> demonstrate it the other way around (ie show a Scheme snippet in which
> add0(0) == add1(0) == 1), because of Scheme's insistence on using recursion
> to implement iteration.

It think it is both possible and easy. Also, citing "X's insistence on Y" as a
cause for (some desirable) A being not easily (or at all) achievable, might
give the impression of a deficiency born out of mere stubborness.

> If you can find a way of making a genuine loop in Scheme, you should
> observe similar behaviour to that of the original Python example.

I hope the code I posted has shown that it is just about as easy to write a
version of DO that is to all extents and purposes identical to CL's eponymous
looping construct as it is to write the one with rebinding semantics that
comes bundled with scheme.

> Please don't falsely attribute any value judgements on the subject, to
> me.

I don't think I have.

By using the formulation "seem to imply" I have made it plain that this is
merely a possible *interpretation* of what you have said. I also hope to have
made it comprehensible why your post might be read in such a way and why
readers of it might profit from additional clarifying information.

'as



More information about the Python-list mailing list