all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Michael Mauger <michael@mauger.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Expansion of #$ in byte-compiled files
Date: Thu, 03 Sep 2015 22:12:04 -0400	[thread overview]
Message-ID: <jwvsi6vj5pb.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <1668732705.1162011.1441310007202.JavaMail.yahoo@mail.yahoo.com> (Michael Mauger's message of "Thu, 3 Sep 2015 19:53:27 +0000 (UTC)")

> Please correct me if I am not right here, but it appears that in
> byte-compiled files (don't always?) expand #$ to the current elisp
> file name.  I wrote a module containing the following code:

>   (message "x: %S" #$)

The issue here is that #$ is a "reader macro", so it is replaced by the
content of load-file-name when this expression is *read*.  When the .el
file is loaded, this expression is read when load-file-name has the
intended value, but when it is compiled, this expression is read during
byte-compilation (i.e. not during any kind of "load"ing) when
load-file-name is nil.  So #$ will be read as if nil appeared there in
the file.  Hence the byte-compiler will generate code which behaves just like

   (message "x: %S" nil)


-- Stefan



      parent reply	other threads:[~2015-09-04  2:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-03 19:53 Expansion of #$ in byte-compiled files Michael Mauger
2015-09-03 21:14 ` Ken Brown
2015-09-03 21:51 ` Kalle Olavi Niemitalo
2015-09-04  1:46   ` Michael Mauger
2015-09-04 14:49     ` Ken Brown
2015-09-04  2:12 ` Stefan Monnier [this message]

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=jwvsi6vj5pb.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=michael@mauger.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.