unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Define works different when Compile and Eval
@ 2024-06-19  9:04 Andrew Tropin
  2024-06-19  9:53 ` Attila Lendvai
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Tropin @ 2024-06-19  9:04 UTC (permalink / raw)
  To: guile-devel

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

Here is a snippet of code, which I expect to produce the same result
with both eval and compile, but the results are different.

When compile is used (define a a) sets a to #<undefined>.

Is it a bug?

--8<---------------cut here---------------start------------->8---
(define-module (2024-06-18-define-bug))

(use-modules (system base compile))

(define (peval e)
  (compile
   e
   #:to 'value
   #:env (resolve-module
          '(2024-06-18-define-bug))))

(define (test-eval teval)
  (teval '(define a 1))
  (teval '(define a a))
  (format #t "a value with ~a is ~a\n" teval (teval 'a)))

(test-eval peval)
(test-eval primitive-eval)

(exit 0)

;; guile -l 2024-06-18-define-bug.scm # output is:
;; a value with #<procedure peval (e)> is #<unspecified>
;; a value with #<procedure primitive-eval (exp)> is 1
--8<---------------cut here---------------end--------------->8---

-- 
Best regards,
Andrew Tropin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-22 16:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19  9:04 Define works different when Compile and Eval Andrew Tropin
2024-06-19  9:53 ` Attila Lendvai
2024-06-21 12:33   ` Andrew Tropin
2024-06-22 12:57     ` Attila Lendvai
2024-06-22 16:45       ` Maxime Devos
2024-06-21 14:40   ` Maxime Devos

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).