public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@red-bean.com>
To: Doug Evans <dje@sebabeach.org>
Cc: cgen@sourceware.org
Subject: Re: Opinions wanted: What should (.list pmacro-name 42) do?
Date: Thu, 20 Aug 2009 18:24:00 -0000	[thread overview]
Message-ID: <8f2776cb0908201124h19b92065w313921eed3c46078@mail.gmail.com> (raw)
In-Reply-To: <4A8D8838.9090708@sebabeach.org>

On Thu, Aug 20, 2009 at 10:30 AM, Doug Evans<dje@sebabeach.org> wrote:
> Hi.
>
> What should the output of
>
> (define-pmacro (foo a) (add a 1))
> (.list foo 42)
>
> be?
>
> Currently the result is (<pmacro> 42)
> where <pmacro> is the pmacro object for "foo".
>
> It's not ideal because it means that a pmacro object "escapes"
> pmacro-processing and can be seen by, for example, rtl compilation.
>
> However, it's not that unexpected.  The user asked for a list containing two
> objects, the pmacro and 42.
> This is akin to saying (list + 42) in Scheme.
>
> We *could* have the pmacro evaluator re-examine the result and if it sees
> (<pmacro> mumble) then re-expand it.  That's what we do for symbols today
> (i.e. if the result of pmacro-expansion is a symbol that names a pmacro, we
> re-evaluate it), but that has problems, e.g.
> http://sourceware.org/ml/cgen/2009-q3/msg00052.html
> and I'm leaning toward removing that behavior.

Macros should definitely be able to expand to calls to other macros
somehow; doesn't (.list 'foo 42) do this?  If it does, then I don't
see much point in allowing (.list foo 42) to do so as well.  The
source world and the value world need to interact only in
easy-to-reason-about ways, or you end up with stuff like m4, which is
just chaos.

This reminds me of the "3-d macro" problem in Scheme, where macros can
place values that can't actually be written in Scheme source code
(procedure objects, say) into the tree that the compiler eventually
sees.  I've always thought the cleanest thing was to reject such code,
as it didn't seem useful, and made a weird breach between macro
expansion time and run time.

  parent reply	other threads:[~2009-08-20 18:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-20 17:30 Doug Evans
2009-08-20 17:44 ` Doug Evans
2009-08-20 18:24 ` Jim Blandy [this message]
2009-08-21  4:30   ` Doug Evans

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

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

  git send-email \
    --in-reply-to=8f2776cb0908201124h19b92065w313921eed3c46078@mail.gmail.com \
    --to=jimb@red-bean.com \
    --cc=cgen@sourceware.org \
    --cc=dje@sebabeach.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).