unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
       [not found] ` <20170624141530.443C5210EB@vcs0.savannah.gnu.org>
@ 2017-06-24 14:26   ` Stefan Monnier
  2017-06-24 14:36     ` Noam Postavsky
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2017-06-24 14:26 UTC (permalink / raw)
  To: emacs-devel; +Cc: Noam Postavsky

>     * lisp/emacs-lisp/eieio-core.el: Confine `cl-declaim' calls to compile
>     time.
[...]
> -  (cl-declaim (optimize (safety 0)))
> +  (eval-when-compile (cl-declaim (optimize (safety 0))))
 
I'd argue that cl-declaim should have no effect when interpreted, just
like (defvar foo).  At least, that's how I understand the difference
between CommonLisp proclaim and declaim.


        Stefan



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-24 14:26   ` [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340) Stefan Monnier
@ 2017-06-24 14:36     ` Noam Postavsky
  2017-06-25 19:34       ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2017-06-24 14:36 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

On Sat, Jun 24, 2017 at 10:26 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>>     * lisp/emacs-lisp/eieio-core.el: Confine `cl-declaim' calls to compile
>>     time.
> [...]
>> -  (cl-declaim (optimize (safety 0)))
>> +  (eval-when-compile (cl-declaim (optimize (safety 0))))
>
> I'd argue that cl-declaim should have no effect when interpreted, just
> like (defvar foo).  At least, that's how I understand the difference
> between CommonLisp proclaim and declaim.

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node104.html (bottom of
page) says:

    declaim {decl-spec}*

    This macro is syntactically like declare and semantically like
    proclaim. It is an executable form and may be used anywhere
    proclaim may be called. However, each decl-spec is not evaluated.

    If a call to this macro appears at top level in a file being
    processed by the file compiler, the proclamations are also made at
    compile time.

Which suggests that declaim's effects are a superset of proclaim's
effects. But then it also says

    As with other defining macros, it is unspecified whether or not
    the compile-time side effects of a declaim persist after the file
    has been compiled

So I guess we could drop the effects at runtime?



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-24 14:36     ` Noam Postavsky
@ 2017-06-25 19:34       ` Stefan Monnier
  2017-06-29  2:04         ` Noam Postavsky
  2017-06-29 19:25         ` Johan Bockgård
  0 siblings, 2 replies; 14+ messages in thread
From: Stefan Monnier @ 2017-06-25 19:34 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Emacs developers

> Which suggests that declaim's effects are a superset of proclaim's
> effects. But then it also says
[...]
> So I guess we could drop the effects at runtime?

I agree that it's not really clear, but when you look at the doc of
proclaim and compare it to that of declaim it seems clear what is the
intention: one is meant to be "runtime only" (which is why it evaluates
its argument and is just a normal function) while the other is designed
such that it can be used at compile-time and only affects the
compilation of the current file (although the doc allows the
implementation to be less careful and let the effect "leak").


        Stefan



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-25 19:34       ` Stefan Monnier
@ 2017-06-29  2:04         ` Noam Postavsky
  2017-06-29 11:46           ` Stefan Monnier
  2017-06-29 19:25         ` Johan Bockgård
  1 sibling, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2017-06-29  2:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

On Sun, Jun 25, 2017 at 3:34 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:

> I agree that it's not really clear, but when you look at the doc of
> proclaim and compare it to that of declaim it seems clear what is the
> intention: one is meant to be "runtime only" (which is why it evaluates
> its argument and is just a normal function) while the other is designed
> such that it can be used at compile-time and only affects the
> compilation of the current file (although the doc allows the
> implementation to be less careful and let the effect "leak").

Sounds reasonable, so should it be just this?

(defmacro cl-declaim (&rest specs)
  "Like `cl-proclaim', but takes any number of unevaluated, unquoted arguments.
Furthermore, the declarations are registered at compile-time."
  (mapc #'cl-proclaim spec))



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-29  2:04         ` Noam Postavsky
@ 2017-06-29 11:46           ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2017-06-29 11:46 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Emacs developers

> Sounds reasonable, so should it be just this?

> (defmacro cl-declaim (&rest specs)
>   "Like `cl-proclaim', but takes any number of unevaluated, unquoted arguments.
> Furthermore, the declarations are registered at compile-time."
>   (mapc #'cl-proclaim spec))

Ideally, we'd want to retract those things when we're done compiling the
current file, but I think the above is an improvement over the current
implementation, yes.


        Stefan



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-25 19:34       ` Stefan Monnier
  2017-06-29  2:04         ` Noam Postavsky
@ 2017-06-29 19:25         ` Johan Bockgård
  2017-06-29 19:46           ` Noam Postavsky
  2017-06-29 20:52           ` Stefan Monnier
  1 sibling, 2 replies; 14+ messages in thread
From: Johan Bockgård @ 2017-06-29 19:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Noam Postavsky, Emacs developers

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> Which suggests that declaim's effects are a superset of proclaim's
>> effects. But then it also says
> [...]
>> So I guess we could drop the effects at runtime?
>
> I agree that it's not really clear, but when you look at the doc of
> proclaim and compare it to that of declaim it seems clear what is the
> intention: one is meant to be "runtime only" (which is why it evaluates
> its argument and is just a normal function) while the other is designed
> such that it can be used at compile-time and only affects the
> compilation of the current file (although the doc allows the
> implementation to be less careful and let the effect "leak").

This is wrong. declaim has run-time effects, just like defvar etc. The
compile-time side effect is that it ALSO affects the compilation of the
remainder of the current file.

http://www.lispworks.com/documentation/HyperSpec/Body/03_bcaa.htm




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-29 19:25         ` Johan Bockgård
@ 2017-06-29 19:46           ` Noam Postavsky
  2017-06-29 20:09             ` Johan Bockgård
  2017-06-29 20:52           ` Stefan Monnier
  1 sibling, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2017-06-29 19:46 UTC (permalink / raw)
  To: Johan Bockgård; +Cc: Stefan Monnier, Emacs developers

On Thu, Jun 29, 2017 at 3:25 PM, Johan Bockgård <bojohan@gnu.org> wrote:

> This is wrong. declaim has run-time effects, just like defvar etc. The
> compile-time side effect is that it ALSO affects the compilation of the
> remainder of the current file.
>
> http://www.lispworks.com/documentation/HyperSpec/Body/03_bcaa.htm

So you don't think this statement allows to omit run-time effects?

    It is not specified whether definitions made available in the
    compilation environment are available in the evaluation
    environment, nor is it specified whether they are available in
    subsequent compilation units or subsequent invocations of the
    compiler.

PS my earlier definition of cl-declaim had 2 bugs in it, I should have written

(defmacro cl-declaim (&rest specs)
  "Like `cl-proclaim', but takes any number of unevaluated, unquoted arguments.
Furthermore the declarations are registered at compile-time."
  (mapc #'cl-proclaim specs)
  nil)



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-29 19:46           ` Noam Postavsky
@ 2017-06-29 20:09             ` Johan Bockgård
  2017-06-29 20:49               ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Johan Bockgård @ 2017-06-29 20:09 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Stefan Monnier, Emacs developers

Noam Postavsky <npostavs@gmail.com> writes:

> On Thu, Jun 29, 2017 at 3:25 PM, Johan Bockgård <bojohan@gnu.org> wrote:
>
>> This is wrong. declaim has run-time effects, just like defvar etc. The
>> compile-time side effect is that it ALSO affects the compilation of the
>> remainder of the current file.
>>
>> http://www.lispworks.com/documentation/HyperSpec/Body/03_bcaa.htm
>
> So you don't think this statement allows to omit run-time effects?
>
>     It is not specified whether definitions made available in the
>     compilation environment are available in the evaluation
>     environment, nor is it specified whether they are available in
>     subsequent compilation units or subsequent invocations of the
>     compiler.

No, evaluation environment != run-time environment.(*)

The Hyperspec says that:

1. [declaim should] make definitions available both in the compilation
   and run-time environments.
2. It is not specified whether definitions [...]
   a) are available in the evaluation environment,
   b) in subsequent compilation units or subsequent invocations of the
      compiler.
3. compile-time side effects happen only [..] at top level.


(*) evaluation environment n. a [kind of] run-time environment in which
    macro expanders and code specified by eval-when to be evaluated are
    evaluated. All evaluations initiated by the compiler take place in
    the evaluation environment.



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-29 20:09             ` Johan Bockgård
@ 2017-06-29 20:49               ` Stefan Monnier
  2017-06-29 22:11                 ` Johan Bockgård
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2017-06-29 20:49 UTC (permalink / raw)
  To: Johan Bockgård; +Cc: Noam Postavsky, Emacs developers

> The Hyperspec says that:
>
> 1. [declaim should] make definitions available both in the compilation
>    and run-time environments.

Hmm... the uses of declaim that I'm familiar with are optimization
settings for the compiler.  These don't "make definitions available"
AFAICT.  If foo.el contains a declaim to set the optimization level,
I don't see why it would make sense for this setting to affect all files
compiled after foo.elc was loaded (I can understand that the spec may
allow such a suboptimal behavior, but not that it would require it).


        Stefan



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-29 19:25         ` Johan Bockgård
  2017-06-29 19:46           ` Noam Postavsky
@ 2017-06-29 20:52           ` Stefan Monnier
  1 sibling, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2017-06-29 20:52 UTC (permalink / raw)
  To: emacs-devel

> This is wrong. declaim has run-time effects, just like defvar etc.

If you put (defvar foo) in foo.el, then compile it, then load foo.elc,
you'll see that this defvar has no runtime effect.

I think cl-declaim should basically behave the same: it holds
compilation directives which should basically only influence the
compilation of the current file.


        Stefan




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-29 20:49               ` Stefan Monnier
@ 2017-06-29 22:11                 ` Johan Bockgård
  2017-06-30  6:06                   ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Johan Bockgård @ 2017-06-29 22:11 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Noam Postavsky, Emacs developers

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> The Hyperspec says that:
>>
>> 1. [declaim should] make definitions available both in the compilation
>>    and run-time environments.
>
> Hmm... the uses of declaim that I'm familiar with are optimization
> settings for the compiler.  These don't "make definitions available"
> AFAICT.  If foo.el contains a declaim to set the optimization level,
> I don't see why it would make sense for this setting to affect all files
> compiled after foo.elc was loaded (I can understand that the spec may
> allow such a suboptimal behavior, but not that it would require it).

In CL declaim can be used to make variables special. (In fact, `special'
is the only declaration that must have an effect in all conforming CL
implementations.)

Also see

https://groups.google.com/forum/#!original/comp.lang.lisp/rO1Vru1fbvI/-3FkSBvlE0gJ



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-29 22:11                 ` Johan Bockgård
@ 2017-06-30  6:06                   ` Stefan Monnier
  2017-07-01  8:59                     ` Johan Bockgård
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2017-06-30  6:06 UTC (permalink / raw)
  To: emacs-devel

> In CL declaim can be used to make variables special. (In fact, `special'
> is the only declaration that must have an effect in all conforming CL
> implementations.)

Right, AFAIK it's largely equivalent to Elisp's (defvar foo).

not sure how it works in CL, but in Elisp, if a file foo.el has

    (defvar foo)
    ...

then `foo` will be treated as dynamically bound in foo.el when the
compiler generate the code for foo.elc.
But loading foo.elc, won't mark `foo` as dynamically bound, so in

    (require 'foo)
    (defun bar (x)
      (let ((foo x))
        (lambda (y) (+ foo y))))

the function `bar` should treat its `foo` binding lexically.


        Stefan


PS: Note I'm really talking about (defvar foo) and not (defvar foo blabla)




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-06-30  6:06                   ` Stefan Monnier
@ 2017-07-01  8:59                     ` Johan Bockgård
  2017-07-01 14:35                       ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Johan Bockgård @ 2017-07-01  8:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> In CL declaim can be used to make variables special. (In fact, `special'
>> is the only declaration that must have an effect in all conforming CL
>> implementations.)
>
> Right, AFAIK it's largely equivalent to Elisp's (defvar foo).
>
> not sure how it works in CL

`proclaim' makes "global declarations", aka "proclamations". `declaim'
is like `proclaim' but also has compile-time effects.




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340)
  2017-07-01  8:59                     ` Johan Bockgård
@ 2017-07-01 14:35                       ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2017-07-01 14:35 UTC (permalink / raw)
  To: emacs-devel

>>> In CL declaim can be used to make variables special. (In fact, `special'
>>> is the only declaration that must have an effect in all conforming CL
>>> implementations.)
>> Right, AFAIK it's largely equivalent to Elisp's (defvar foo).
>> not sure how it works in CL

> `proclaim' makes "global declarations", aka "proclamations". `declaim'
> is like `proclaim' but also has compile-time effects.

That description is sufficiently broad that it accepts both your
interpretation and mine.


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-07-01 14:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20170624141528.514.4459@vcs0.savannah.gnu.org>
     [not found] ` <20170624141530.443C5210EB@vcs0.savannah.gnu.org>
2017-06-24 14:26   ` [Emacs-diffs] master c75eb10: Don't change byte-compile-delete-errors at runtime (Bug#27340) Stefan Monnier
2017-06-24 14:36     ` Noam Postavsky
2017-06-25 19:34       ` Stefan Monnier
2017-06-29  2:04         ` Noam Postavsky
2017-06-29 11:46           ` Stefan Monnier
2017-06-29 19:25         ` Johan Bockgård
2017-06-29 19:46           ` Noam Postavsky
2017-06-29 20:09             ` Johan Bockgård
2017-06-29 20:49               ` Stefan Monnier
2017-06-29 22:11                 ` Johan Bockgård
2017-06-30  6:06                   ` Stefan Monnier
2017-07-01  8:59                     ` Johan Bockgård
2017-07-01 14:35                       ` Stefan Monnier
2017-06-29 20:52           ` Stefan Monnier

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