Define works different when Compile and Eval

2024-06-19 Thread Andrew Tropin
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)) (

Re: Define works different when Compile and Eval

2024-06-19 Thread Attila Lendvai
> (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

Re: Define works different when Compile and Eval

2024-06-21 Thread Andrew Tropin
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

RE: Define works different when Compile and Eval

2024-06-21 Thread Maxime Devos
>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

Re: Define works different when Compile and Eval

2024-06-22 Thread Attila Lendvai
> > 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`:

RE: Define works different when Compile and Eval

2024-06-22 Thread Maxime Devos
> > > 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