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

Hi Thomas,

Thomas Morley <thomasmorley65@gmail.com> writes:

> 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?

Neither.  This is a case of unspecified behavior, and the behavior of
our compiler differs from that of our interpreter.  You will notice
similar discrepancies when comparing two literal lists or strings, where
our compiler will aggressively unify literals within a compilation unit,
and our interpreter does not:

--8<---------------cut here---------------start------------->8---
GNU Guile 2.2.4
Copyright (C) 1995-2017 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)> (eqv? "hello" "hello")
$1 = #t
scheme@(guile-user)> ,o interp #t
scheme@(guile-user)> (eqv? "hello" "hello")
$2 = #f
scheme@(guile-user)>
--8<---------------cut here---------------end--------------->8---

     Regards,
       Mark



  reply	other threads:[~2019-06-16 10:32 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
2019-06-16 10:32     ` Mark H Weaver [this message]
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=87d0jd3jm1.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-user@gnu.org \
    --cc=thomasmorley65@gmail.com \
    /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).