What is a function parameter =[] for?

Jussi Piitulainen harvest at should.be.invalid
Wed Nov 25 13:30:07 EST 2015


Marko Rauhamaa writes:
> Jussi Piitulainen writes:
>
>> You know, people have developed further ways to talk about these
>> things precisely because substitution semantics is inadequate for
>> what they wanted to talk about.
>
> "Assignment" is what everybody uses and understands.

You can tell that to those who insist otherwise, and to those who
understand it differently, and to those who are just confused.
All are around in this thread.

But yes, I would find it easier if variables could be called variables,
assignment could be called assignment, and binding could be called
binding even in Python (variations of the last one somewhat work; the
former two are problematic in the way that any mention of regular
expressions is, whether you've noticed it or not).

>> Not substituted to the program text - who would even think that?
>
> Actually, if Scheme didn't possess set! et al, we would be talking
> about true binding. For example, the function
>
>    (define (sum numbers)
>      (let loop ((total 0) (remaining numbers))
>        (if (null? remaining)
>            total
>            (loop (+ total (car remaining)) (cdr remaining)))))
>
> can be described and effectively implemented using true, syntactic
> binding. To execute such code, you start with an expression, say,
> (sum '(1 2 3 4 5)) and keep on rewriting the expression until you can't
> rewrite it anymore.

Interesting. Can you just keep reducing / expanding the expression
without reference to an environment? I see how it's easy to talk about
assignment because one can talk about something else, but I'm not yet
quite sure how you intend to handle recursion.

==> (let loop ((total 0) (remaining '(1 2 3 4 5)))
       (if (null? remaining)
           total
           (loop (+ total (car remaining)) (cdr remaining))))

Now what? Rewrite using a call-by-value fixed-point operator and keep
insisting that you just saw a squirrel? Or rewrite with respect to an
environment where loop is bound to a lambda expression that is closed in
that same environment and this is somehow true substitution and you just
saw a squirrel? Link to a Wikipedia page that tells what call-by-value
and call-by-reference are and remind me that one should really talk
about passing a reference by value?

That last one is as irrelevant as squirrels, by the way.

> The availability of set! forces the implementation to generate a
> memory slot for each binding, turning the binding semantics into an
> assignment semantics.

Thank you.

I'm probably out now.



More information about the Python-list mailing list