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 #.
Is it a bug?
--8<---cut here---start->8---
(define-module (2024-06-18-define-bug))
(
> (define (test-eval teval)
> (teval '(define a 1))
if you want this^ to be actually defined while compilation is
happening (i.e. in the compilation stage; see staged computing), then you need
to use an (eval-when (expand) ...) wrapper
around it.
https://www.gnu.org/software/guile/manual/guile.h
On 2024-06-19 09:53, Attila Lendvai wrote:
>> (define (test-eval teval)
>> (teval '(define a 1))
>
> if you want this^ to be actually defined while compilation is
> happening (i.e. in the compilation stage; see staged computing), then
> you need to use an (eval-when (expand) ...) wrapper around it
>compile does not evaluate (aka load) the definitions, it only compiles them.
Usually, sure, but in the code ‘#:to ‘value” was set. From the manual:
>As discussed before (see Object File Format), bytecode is in ELF format, ready
>to be serialized to disk. But when compiling Scheme at run time, yo
> > if you want this^ to be actually defined while compilation is
> > happening (i.e. in the compilation stage; see staged computing), then
> > you need to use an (eval-when (expand) ...) wrapper around it.
>
>
> Thank you for the reply! Not sure what you mean. The following code
> defines `a`:
> > > if you want this^ to be actually defined while compilation is
> > > happening (i.e. in the compilation stage; see staged computing), then
> > > you need to use an (eval-when (expand) ...) wrapper around it.
>
>
> > Thank you for the reply! Not sure what you mean. The following code
> > defi