[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Expansion of #$ in byte-compiled files
From: |
Stefan Monnier |
Subject: |
Re: Expansion of #$ in byte-compiled files |
Date: |
Thu, 03 Sep 2015 22:12:04 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> 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