guile-devel
[Top][All Lists]
Advanced

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

Define works different when Compile and Eval


From: Andrew Tropin
Subject: Define works different when Compile and Eval
Date: Wed, 19 Jun 2024 13:04:44 +0400

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: signature.asc
Description: PGP signature


reply via email to

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