unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Thomas Morley <thomasmorley65@gmail.com>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-user@gnu.org
Subject: Re: Self-evaluating function and closure
Date: Sun, 16 Jun 2019 12:21:09 +0200	[thread overview]
Message-ID: <CABsfGyUktCR3hpgfJ5eoCtGwPDnntCxuY_0m+kXbFj7Z6nzJbA@mail.gmail.com> (raw)
In-Reply-To: <87o92x3lqm.fsf@netris.org>

[-- Attachment #1: Type: text/plain, Size: 3496 bytes --]

Am So., 16. Juni 2019 um 11:49 Uhr schrieb Mark H Weaver <mhw@netris.org>:
>
> Hello again Vladimir,
>
> Vladimir Zhbanov <vzhbanov@gmail.com> 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
>
Hi Mark,

always interested in guile developments with regard to lilypond I
noticed some inconsistence with my local lilypond-using-guile-2.9.2
installation.
I think I could break it down to pure guile (no lilypond)

(1) The already stated behaviour:
~$ guile
GNU Guile 2.9.2
Copyright (C) 1995-2019 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (define (function-generator)
                      (let ((func #f))
                        (lambda () (set! func (let a () a)) func)))
scheme@(guile-user)> (define x (function-generator))
scheme@(guile-user)> (define y (function-generator))
scheme@(guile-user)> (write (version))
"2.9.2"
scheme@(guile-user)> (format #t "\nTEST: ~a" (eq? (x) (y)))

TEST: #t
$1 = #t

(2) Doing it in a .scm-file (attached)
~$ guile --no-auto-compile eq-tst.scm
"2.9.2"
TEST: #f

Did I something wrong or is it a bug?

Cheers,
  Harm

[-- Attachment #2: eq-tst.scm --]
[-- Type: text/x-scheme, Size: 260 bytes --]


(define (function-generator)
                      (let ((func #f))
                        (lambda () (set! func (let a () a)) func)))

(define x (function-generator))
(define y (function-generator))

(write (version))
(format #t "\nTEST: ~a" (eq? (x) (y)))

  reply	other threads:[~2019-06-16 10:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 20:29 Self-evaluating function and closure Vladimir Zhbanov
2019-06-15 19:35 ` John Cowan
2019-06-16  0:39   ` Mark H Weaver
2019-06-16  0:36 ` Mark H Weaver
2019-06-16  9:02   ` Vladimir Zhbanov
2019-06-16 10:09     ` Mark H Weaver
2019-06-17  8:03       ` Vladimir Zhbanov
2019-06-16  9:47 ` Mark H Weaver
2019-06-16 10:21   ` Thomas Morley [this message]
2019-06-16 10:32     ` Mark H Weaver
2019-06-16 10:42       ` Thomas Morley
2019-06-16 11:29 ` Mark H Weaver
2019-06-17  8:48   ` Vladimir Zhbanov
2019-06-17 14:21     ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABsfGyUktCR3hpgfJ5eoCtGwPDnntCxuY_0m+kXbFj7Z6nzJbA@mail.gmail.com \
    --to=thomasmorley65@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).