[Top][All Lists]

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

Re: GNU Guile 2.9.9 Released [beta]

From: Andy Wingo
Subject: Re: GNU Guile 2.9.9 Released [beta]
Date: Tue, 14 Jan 2020 22:17:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

On Tue 14 Jan 2020 21:13, Stefan Israelsson Tampe <address@hidden> writes:

> Okey, here is another case that fails with the patch that prevents identity 
> misses for toplevels e.g we need similar fixes for anonymous functions.
> (define-module (b)
>   #:export (q))
> (define h (make-hash-table))
> (define (method f)
>   (hash-set! h f 1)
>   f)
> (define q (method (lambda x x)))
> (pk (hash-ref h q))
> This fails with (#f)
> I solved this in my code by placing the method function in another module.

Interestingly, this case is not really related to the declarative
bindings optimization, letrectification, or other things.  It's the same

  (let ((h (make-hash-table)))
    (define (method f)
      (hash-set! h f 1)
    (let* ((q (let ((f (lambda x x)))
                (method f))))
      (pk (hash-ref h q))))

I.e. no top-level bindings are needed.  This prints #f in releases as
old as 2.0.14 and probably older :)  It optimizes as:

  (let* ((h (make-hash-table))
         (q (begin
              (hash-set! h (lambda x x) 1)
              (lambda x x))))
    (pk (hash-ref h q)))

So, not a recent change.  Of course we can discuss whether it's the
right thing or not!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]