unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Drew Adams <drew.adams@oracle.com>
Cc: Juanma Barranquero <lekktu@gmail.com>, 13052@debbugs.gnu.org
Subject: bug#13052: 24.3.50; mention recent change of `kbd' to a function in NEWS
Date: Sun, 02 Dec 2012 12:33:11 +0100	[thread overview]
Message-ID: <87wqx0r8nc.fsf@web.de> (raw)
In-Reply-To: <8B94F420D989475D8089DCF31ECF8EAC@us.oracle.com> (Drew Adams's message of "Sat, 1 Dec 2012 18:18:04 -0800")

"Drew Adams" <drew.adams@oracle.com> writes:

> > It's not related to pure storage, but to whether the function is
> > "pure" (without side effecs). If the function is pure and the
> > arguments satisfy `macroexp-const-p' it is possible to do some
> > optimization during byte-compilation. See lisp/emacs-lisp/byte-opt.el,
> > around line 560 or so.
>
> Thanks.  So I guess that means that if I have a similar (e.g.,
> identical, for discussion) function and I put property `pure' on it
> then I will get the same optimization?

Looking shortly at the code, I see this paragraph, which seems to say it
all:

;; pure functions are side-effect free functions whose values depend
;; only on their arguments. For these functions, calls with constant
;; arguments can be evaluated at compile time. This may shift run time
;; errors to compile time.

So, IIUC, the only optimization you get is that errors happen at
compile-time that would otherwise happen at run-time.  E.g. like for

  (symbol-name "Not-a-symbol")

OTOH, this would become a string when compiled (because it's evaluated
at compile-time):

  (symbol-name 'a-symbol)

> What happens if someone erroneously adds that property to a function
> that is not pure but whose args all satisfy `macroexp-const-p'?  Do
> you just lose the optimization or could something much worse happen?

The funcall and the side-effects happen at compile-time.  In most cases,
this is probably quite bad.

> In any case, this property should be documented.

If I understood the code correctly, this could indeed be a bit useful.
But maybe it is still experimental... it's no big loss not to use it.
And we can be happy that it is no "Do not use this".


Regards,

Michael.





  parent reply	other threads:[~2012-12-02 11:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-02  0:28 bug#13052: 24.3.50; mention recent change of `kbd' to a function in NEWS Drew Adams
2012-12-02  1:52 ` Juanma Barranquero
2012-12-02  2:18   ` Drew Adams
2012-12-02  2:26     ` Juanma Barranquero
2012-12-02  3:36       ` Drew Adams
2012-12-02  3:50         ` Juanma Barranquero
2012-12-02  4:07           ` Drew Adams
2012-12-02  4:19             ` Juanma Barranquero
2012-12-02  4:50               ` Drew Adams
2012-12-02 11:33     ` Michael Heerdegen [this message]
2012-12-02  9:14 ` Chong Yidong
2012-12-02 17:13   ` Drew Adams
2012-12-06 18:02   ` Drew Adams

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=87wqx0r8nc.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=13052@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=lekktu@gmail.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.
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).