unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Andreas Rottmann <a.rottmann@gmx.at>
To: Hans Aberg <haberg-1@telia.com>
Cc: guile-user@gnu.org
Subject: Re: Problem with define-macro from compiled file (Guile 1.9)
Date: Sat, 08 Jan 2011 00:22:58 +0100	[thread overview]
Message-ID: <87y66ws3hp.fsf@vir.lan> (raw)
In-Reply-To: <CD262A7D-EA9E-4174-840E-1E0AA2A89AD5@telia.com> (Hans Aberg's message of "Fri, 7 Jan 2011 09:53:44 +0100")

Hans Aberg <haberg-1@telia.com> writes:

> 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:
>
> [...]

It's not only easier, it also not inherently broken (as `define-macro'
is).  See <http://en.wikipedia.org/wiki/Hygienic_macro> for a discussion
of the hygiene issue.

For example, the following invocation of `when' will break when
implemented with `define-macro' as above:

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

Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.yi.org/>



  reply	other threads:[~2011-01-07 23:22 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
2011-01-07 23:22   ` Andreas Rottmann [this message]
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=87y66ws3hp.fsf@vir.lan \
    --to=a.rottmann@gmx.at \
    --cc=guile-user@gnu.org \
    --cc=haberg-1@telia.com \
    /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).