[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Another question about lambdas
From: |
Michael Heerdegen |
Subject: |
Re: Another question about lambdas |
Date: |
Thu, 19 Jan 2023 14:32:24 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Emanuel Berg <incal@dataswamp.org> writes:
> I mean, why do we have all this f(x) and g() { x } notation in
> programming if it is, or can be, actually the same x as some
> x outside of that? Just looking at it, and writing it, tells
> me, "hey, this is an x of it's own". But with dynamic scope it
> sometimes isn't and you have to look somewhere else, execute
> code in your head etc to find out.
> [...]
>
> > And a lot have their problems with lexical binding
> > and closures.
>
> What do you mean, what's up with them?
As long as there are only individual closures that only treat one
individual variable it's all trivial, yes.
The non-trivial aspects start when several closures, used in different
parts of a program, share the same variables of the same environment,
or partly share an environment partly. Or a variable of the same name
appears multiple times in different environments with different bindings.
The "execute code in your head" thing is a question of code complexity,
not one of scoping.
Michael.