unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Brinkhoff <lars@nocrew.org>
Subject: Re: Invalid read syntax for compiled bool vector
Date: 26 Apr 2004 09:27:33 +0200	[thread overview]
Message-ID: <857jw35hcq.fsf@junk.nocrew.org> (raw)
In-Reply-To: <E1BFdNk-0003Ia-Oq@fencepost.gnu.org>

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/

      parent reply	other threads:[~2004-04-26  7:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [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

  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=857jw35hcq.fsf@junk.nocrew.org \
    --to=lars@nocrew.org \
    /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).