unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dancol@dancol.org>
To: Drew Adams <drew.adams@oracle.com>,
	 Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] trunk r117002: Correctly treat progn contents as toplevel forms when byte compiling
Date: Tue, 22 Apr 2014 14:05:27 -0700	[thread overview]
Message-ID: <5356D997.2030006@dancol.org> (raw)
In-Reply-To: <dd3feb61-1007-4608-ad3d-bf231409d54a@default>

[-- Attachment #1: Type: text/plain, Size: 2674 bytes --]

On 04/22/2014 01:41 PM, Drew Adams wrote:
>>>> The SBCL and ECL behavior is what I'd expect from reading the spec, but
>>>> maybe I misunderstood something.
>>>
>>> Hm.  What part of the spec do you think gives the impression that
>>> `defmacro' behavior is defined only at top level?
>>
>> defmacro is specced to "define[] name as a macro by associating a macro
>> function with that name in the global environment". 
> 
>> Like any form, it's supposed to do that when it's evaluated,
> 
> Yes, anywhere and anywhen it's evaluated, including from a file at any
> level.  And including when invoked from running code.  And including
> `defmacro' forms that are generated and eval'd on the fly.

That goes without saying.

> But I do see now that you allowed for `progn' contexts, at least.
> I guess you meant any context, like progn, which evaluates the
> `defmacro' at load or compile time.
> 
> It does not say anything about `defmacro' inside a defun signaling a
> compile-time error, as opposed to doing what you write above: "have no
> effect until the defun is called".  A priori, when the defun is called
> the `defmacro' inside it should be evaluated, defining the macro
> normally, no?

Neither did I. I was imprecise: the code I mentioned compiles without
error. It signals an error at runtime because there is no function
called `bar'. The function is trying to call `bar' because the macro
`bar' wasn't expanded during compilation.

> It says clearly that IF you expect the macro to be available to code
> in the same file at compile time for that file, THEN you must ensure
> that it gets evaluated at compile time.  If not, then not.
> 
>> It's because of this special case that a normal defmacro, not wrapped in
>> an eval-when, has any effect on compilation of forms in the same file. A
>> defmacro inside a defun isn't covered by this special case, so its
>> behavior should revert to the normal behavior for forms.
> 
> Which is what?  Why isn't it that the embedded `defmacro' would, as you
> said "have no effect until the defun is called"?

"No effect until the defun is called" is the correct behavior.

>> SBCL and ECL implement this model of evaluation. CLISP's behavior
>> appears to be incorrect here.
> 
> I don't see that either of those behaviors realizes the exclusive truth
> here.  All I see that passage saying is that you must not expect a
> `defvar' embedded in a defun to have an effect, at compile time, on
> subsequent code located in the same file.  I don't see that as a call
> to raise a compile-time error.

There is no compile-time error; sorry for the misunderstanding.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

  reply	other threads:[~2014-04-22 21:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1WcAcP-0006zy-MJ@vcs.savannah.gnu.org>
2014-04-21 15:09 ` [Emacs-diffs] trunk r117002: Correctly treat progn contents as toplevel forms when byte compiling Stefan Monnier
2014-04-21 17:44   ` Daniel Colascione
2014-04-21 22:09     ` Stefan Monnier
2014-04-21 22:29       ` Daniel Colascione
2014-04-22  2:09         ` Stefan Monnier
2014-04-22  2:21           ` Daniel Colascione
2014-04-22  4:25             ` Stefan Monnier
2014-04-22  4:46               ` Daniel Colascione
2014-04-22 15:06                 ` Stefan Monnier
2014-04-22 17:22                   ` Daniel Colascione
2014-04-22 18:13                     ` Daniel Colascione
2014-04-22 18:37                       ` Stefan Monnier
2014-04-22 19:08                         ` Daniel Colascione
2014-04-22 18:44                       ` Drew Adams
2014-04-22 19:23                         ` Daniel Colascione
2014-04-22 19:59                           ` Drew Adams
2014-04-22 20:10                             ` Daniel Colascione
2014-04-22 20:41                               ` Drew Adams
2014-04-22 21:05                                 ` Daniel Colascione [this message]
2014-04-23  0:50                                 ` Stephen J. Turnbull
2014-04-22 18:29                     ` Stefan Monnier
2014-04-22 15:20                 ` Stefan Monnier
2014-04-22 17:04                   ` Daniel Colascione

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/emacs/

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

  git send-email \
    --in-reply-to=5356D997.2030006@dancol.org \
    --to=dancol@dancol.org \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).