unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Hans Aberg <haberg-1@telia.com>
To: guile-user@gnu.org
Subject: Re: Problem with define-macro from compiled file (Guile 1.9)
Date: Fri, 7 Jan 2011 09:53:44 +0100	[thread overview]
Message-ID: <CD262A7D-EA9E-4174-840E-1E0AA2A89AD5@telia.com> (raw)
In-Reply-To: <19750.1932.709386.744882@vagabond.local>

On 6 Jan 2011, at 19:18, Patrick Bernaud wrote:

> I have a case where a macro is defined in a file that is then loaded
> by another which makes use of the macro. And it produces a 'wrong type
> to apply' error from the VM.
>
> (Works fine with GUILE_AUTO_COMPILE=0 and compiled files removed).
>
> For example, with the 'when' macro from the manual:
>
> -%<---- when.scm ----%<-
> (define-macro (when cond exp . rest)
> `(if ,cond
>      (begin ,exp . ,rest)))
> -%<---- when.scm ----%<-
>
> -%<---- test.scm ----%<-
> (load "when.scm")
> (when #t (display "Launching missiles!\n"))
> -%<---- test.scm ----%<-

If you are writing your own macro, I find 'define-syntax' easier:

(use-syntax (ice-9 syncase))

(define-syntax when
  (syntax-rules ()
    ((when cond x ...)
      (if cond (begin x ...)))
))

(when #t (display "Launching missiles!\n"))





  parent reply	other threads:[~2011-01-07  8:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-06 18:18 Problem with define-macro from compiled file (Guile 1.9) Patrick Bernaud
2011-01-06 23:58 ` Ludovic Courtès
2011-01-07  8:53 ` Hans Aberg [this message]
2011-01-07 23:22   ` Andreas Rottmann
2011-01-08  9:46     ` Hans Aberg
2011-01-08 12:00     ` Predicate of define-syntax Hans Aberg

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=CD262A7D-EA9E-4174-840E-1E0AA2A89AD5@telia.com \
    --to=haberg-1@telia.com \
    --cc=guile-user@gnu.org \
    /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).