osdir.com

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

Any SML coders able to translate this to Python?


Chris Angelico <rosuav at gmail.com>:

> On Thu, Sep 6, 2018 at 6:44 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> And even more idiomatically, Python doesn't require a new scope just
> for a new variable. So a much more idiomatic translation would be to
> simply ensure that the inner variable can't collide, and then ignore
> the function boundary. And I'm not sure if there even is a name
> collision. What's the issue with scoping at all here? What's the inner
> function actually achieving?

We can debate what the inner function is achieving. The main point is
that functional languages create an inner function for each "let"
statement. Steve was wondering what "let" meant, and the Python code--I
hope--helped illustrate it.

Typical Scheme code is riddled with inner functions. Local variables?
An inner function. A loop? An inner function. Exception handling? An
inner function.

Scheme can also be written procedurally through macros, but those macros
generate inner functions.


Marko