bug-guile
[Top][All Lists]
Advanced

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

bug#52112: Compilation of macro returning record type fails


From: Taylan Kammer
Subject: bug#52112: Compilation of macro returning record type fails
Date: Fri, 26 Nov 2021 19:54:36 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2

On 25.11.2021 18:45, Jean Abou Samra wrote:
> Record types are self-evaluating:
> 
> scheme@(guile-user)> (eval (make-record-type 'my-record '()) (current-module))
> $1 = #<record-type my-record>
> 
> Yet, when a macro returns a record type, Guile fails
> to byte-compile the code, even though the execution
> (via the evaluator) works fine. Here is a simple example:
> 
> 
> (define-macro (my-macro)
>   (make-record-type 'my-record-2 '()))
> 
> (display (my-macro))
> (newline)
> 
> 
> Execution log:
> 
> 
> $ guile --no-auto-compile test.scm
> #<record-type my-record-2>
> 
> $ guile test.scm
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;       or pass the --no-auto-compile argument to disable.
> ;;; compiling /home/jean/test.scm
> ;;; WARNING: compilation of /home/jean/test.scm failed:
> ;;; unhandled constant #<record-type my-record-2>
> #<record-type my-record-2>
> 
> This is with Guile version 3.0.5.130-5a1e7.

I don't think that's supposed to work.  I find it surprising that
record-type objects are self-evaluating, and in any case they can't
be turned into bytecode.

Your macro could return code that evaluates to a record definition.
Would that solve your use-case?

-- 
Taylan





reply via email to

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