unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Taylan Kammer <taylan.kammer@gmail.com>
To: Jean Abou Samra <jean@abou-samra.fr>, 52112@debbugs.gnu.org
Subject: bug#52112: Compilation of macro returning record type fails
Date: Fri, 26 Nov 2021 19:54:36 +0100	[thread overview]
Message-ID: <5a97c5fd-ee56-e636-ae18-679570e2502b@gmail.com> (raw)
In-Reply-To: <b0892608-0775-b5b0-b417-af3086022df7@abou-samra.fr>

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	other threads:[~2021-11-26 18:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25 17:45 bug#52112: Compilation of macro returning record type fails Jean Abou Samra
2021-11-26 18:54 ` Taylan Kammer [this message]
2021-11-26 19:02   ` Jean Abou Samra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5a97c5fd-ee56-e636-ae18-679570e2502b@gmail.com \
    --to=taylan.kammer@gmail.com \
    --cc=52112@debbugs.gnu.org \
    --cc=jean@abou-samra.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).