bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invalid read syntax for compiled bool vector


From: Lars Brinkhoff
Subject: Re: Invalid read syntax for compiled bool vector
Date: 26 Apr 2004 09:27:33 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]