[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Self-evaluating function and closure
From: |
Mark H Weaver |
Subject: |
Re: Self-evaluating function and closure |
Date: |
Sun, 16 Jun 2019 05:47:02 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Hello again Vladimir,
Vladimir Zhbanov <address@hidden> writes:
> - Is there a way to work around this (either using the above 'let'
> construct or anything else)?
I'm not quite sure how to answer this question because I don't know what
your requirements are.
If you need to generate unique tags, any mutable object will do, e.g. a
vector, list or string with at least one element that is not a literal.
For example, (list #f), (vector #f), and (string #\a) must allocate a
fresh object every time, but (list), (vector), (string), '(#f), #(#f),
and "foo" may return the same object every time.
If you need to generate a unique _procedure_, there's only one
future-proof way to do it: the new procedure must behave differently
than every other procedure, for some input.
It's a mistake to expect procedures with equivalent behavior to be
distinguishable in Scheme. If you feel that you need this, I would like
to understand why.
Note that 'eq?' is the same as 'eqv?' when applied to procedures (and
most other types), and that Scheme 'eqv?' historically implements an
approximation of "operational equivalence". That language was explicit
in the R3RS, which defined 'eqv?' this way:
The eqv? procedure implements an approximation to the relation of
operational equivalence. It returns #t if it can prove that obj1 and
obj2 are operationally equivalent. If it can't, it always errs on the
conservative side and returns #f.
with "operational equivalence" defined as follows:
Two objects are operationally equivalent if and only if there is no
way that they can be distinguished, using Scheme primitives other than
eqv? or eq? or those like memq and assv whose meaning is defined
explicitly in terms of eqv? or eq?. It is guaranteed that objects
maintain their operational identity despite being named by variables
or fetched from or stored into data structures.
More recent Scheme standards have dropped this language, because the
Scheme authors were not entirely satisfied with this definition and were
unable to formulate a better one, but nonetheless "operational
equivalence" remains the closest thing I've seen to a unifying principle
of the meaning of Scheme 'eqv?'.
Regards,
Mark
Re: Self-evaluating function and closure, Mark H Weaver, 2019/06/16