* Invalid read syntax for compiled bool vector @ 2004-04-19 7:41 Lars Brinkhoff [not found] ` <E1BFdNk-0003Ia-Oq@fencepost.gnu.org> 0 siblings, 1 reply; 2+ messages in thread From: Lars Brinkhoff @ 2004-04-19 7:41 UTC (permalink / raw) I run these forms (in the *scratch* buffer or with M-C-x) to create a source file and byte-compile it: (with-temp-file "test.el" (princ `(defun foo () ,(let ((vec (make-bool-vector 20 t))) (dolist (i '(11 13 16 18) vec) (aset vec i nil)))) (current-buffer))) (byte-compile-file "test.el") When I load the compiled file: (load-file "test.elc") I get this error: Invalid read syntax: "#&..." The pattern in the last 12 elements of the bool vector is what triggers the error. The contents of the first 8 elements doesn't seem to affect the result. This happens in both GNU Emacs 21.3 and 20.7, running in Debian GNU/Linux on a PowerPC. -- Lars Brinkhoff, Services for Unix, Linux, GCC, HTTP Brinkhoff Consulting http://www.brinkhoff.se/ ^ permalink raw reply [flat|nested] 2+ messages in thread
[parent not found: <E1BFdNk-0003Ia-Oq@fencepost.gnu.org>]
* Re: Invalid read syntax for compiled bool vector [not found] ` <E1BFdNk-0003Ia-Oq@fencepost.gnu.org> @ 2004-04-26 7:27 ` Lars Brinkhoff 0 siblings, 0 replies; 2+ messages in thread From: Lars Brinkhoff @ 2004-04-26 7:27 UTC (permalink / raw) Richard Stallman <rms@gnu.org> writes: > (with-temp-file "test.el" > (princ `(defun foo () > ,(let ((vec (make-bool-vector 20 t))) > (dolist (i '(11 13 16 18) vec) > (aset vec i nil)))) > (current-buffer))) > > When I run that, it asks me what coding system to use when saving it. > > When I add ;; -*-coding: no-conversion; -*- as the first line, > there is no problem. Apparently, you have to bind coding-system-for-write before writing a source file with a literal bool-vector constant in it, or else Emacs will either ask the user for the coding system, or write the file using some default coding system which may not do the right thing. Also, you have to bind coding-system-for-read before byte-compiling such a file: (let ((coding-system-for-write 'no-conversion)) (with-temp-file "test.el" (prin1 `(defun foo () ,(let ((vec (make-bool-vector 20 t))) (dolist (i '(11 13 16 18) vec) (aset vec i nil)))) (current-buffer)))) (let ((coding-system-for-read 'no-conversion)) (byte-compile-file "test.el")) (load-file "test.elc") In contrast, you don't have to bind coding-system-for-read when byte- compiling a source file with a string constant: (let ((coding-system-for-write 'no-conversion)) (with-temp-file "test.el" (insert (format "(defun foo () \"%s\")" "\377\327\n")))) (byte-compile-file "test.el") (load-file "test.elc") Here, the string has the same binary data as the bool vector, but the compiler handles it more gracefully, in my opinion. I guess this isn't exactly a bug, but perhaps the Emacs Lisp manual should say something about binding coding-system-for-read and coding-system-for-write when reading and writing source files. -- Lars Brinkhoff, Services for Unix, Linux, GCC, HTTP Brinkhoff Consulting http://www.brinkhoff.se/ ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-04-26 7:27 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-04-19 7:41 Invalid read syntax for compiled bool vector Lars Brinkhoff [not found] ` <E1BFdNk-0003Ia-Oq@fencepost.gnu.org> 2004-04-26 7:27 ` Lars Brinkhoff
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).