* 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; 14+ 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] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
[not found] ` <E1BFdNk-0003Ia-Oq@fencepost.gnu.org>
@ 2004-04-26 7:27 ` Lars Brinkhoff
2004-04-26 14:10 ` Richard Stallman
0 siblings, 1 reply; 14+ 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] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-26 7:27 ` Lars Brinkhoff
@ 2004-04-26 14:10 ` Richard Stallman
2004-04-26 16:08 ` Andreas Schwab
0 siblings, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2004-04-26 14:10 UTC (permalink / raw)
Cc: emacs-devel
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.
I guess we should change the syntax for bool-vectors
so as to put just 4 bits into each character.
The question is how to do that in a somewhat compatible way.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-26 14:10 ` Richard Stallman
@ 2004-04-26 16:08 ` Andreas Schwab
2004-04-26 17:47 ` Lars Brinkhoff
2004-04-27 16:28 ` Richard Stallman
0 siblings, 2 replies; 14+ messages in thread
From: Andreas Schwab @ 2004-04-26 16:08 UTC (permalink / raw)
Cc: Lars Brinkhoff, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> 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.
>
> I guess we should change the syntax for bool-vectors
> so as to put just 4 bits into each character.
> The question is how to do that in a somewhat compatible way.
The print syntax could use octal or hexadecimal escapes in the bit string.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-26 16:08 ` Andreas Schwab
@ 2004-04-26 17:47 ` Lars Brinkhoff
2004-04-26 22:01 ` Andreas Schwab
2004-04-27 16:28 ` Richard Stallman
1 sibling, 1 reply; 14+ messages in thread
From: Lars Brinkhoff @ 2004-04-26 17:47 UTC (permalink / raw)
Cc: rms, emacs-devel
Andreas Schwab <schwab@suse.de> writes:
> Richard Stallman <rms@gnu.org> writes:
> > 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.
> > I guess we should change the syntax for bool-vectors so as to put
> > just 4 bits into each character. The question is how to do that
> > in a somewhat compatible way.
> The print syntax could use octal or hexadecimal escapes in the bit string.
Yes. Since the print syntax for bool-vectors looks like strings, I
would sugggest doing whatever the print syntax for strings does.
--
Lars Brinkhoff, Services for Unix, Linux, GCC, HTTP
Brinkhoff Consulting http://www.brinkhoff.se/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-26 17:47 ` Lars Brinkhoff
@ 2004-04-26 22:01 ` Andreas Schwab
2004-04-26 22:53 ` David Kastrup
2004-04-27 16:29 ` Richard Stallman
0 siblings, 2 replies; 14+ messages in thread
From: Andreas Schwab @ 2004-04-26 22:01 UTC (permalink / raw)
Cc: rms, emacs-devel
Lars Brinkhoff <lars@nocrew.org> writes:
> Andreas Schwab <schwab@suse.de> writes:
>> Richard Stallman <rms@gnu.org> writes:
>> > 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.
>> > I guess we should change the syntax for bool-vectors so as to put
>> > just 4 bits into each character. The question is how to do that
>> > in a somewhat compatible way.
>> The print syntax could use octal or hexadecimal escapes in the bit string.
>
> Yes. Since the print syntax for bool-vectors looks like strings, I
> would sugggest doing whatever the print syntax for strings does.
I have now changed the print syntax to always use octal escapes for
non-ascii characters in the bool-vector string. This way the string will
always be read as unibyte string, avoiding all coding issues.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-26 22:01 ` Andreas Schwab
@ 2004-04-26 22:53 ` David Kastrup
2004-04-27 12:42 ` Andreas Schwab
2004-04-27 16:29 ` Richard Stallman
1 sibling, 1 reply; 14+ messages in thread
From: David Kastrup @ 2004-04-26 22:53 UTC (permalink / raw)
Cc: Lars Brinkhoff, rms, emacs-devel
Andreas Schwab <schwab@suse.de> writes:
> Lars Brinkhoff <lars@nocrew.org> writes:
>
> > Yes. Since the print syntax for bool-vectors looks like strings,
> > I would sugggest doing whatever the print syntax for strings does.
>
> I have now changed the print syntax to always use octal escapes for
> non-ascii characters in the bool-vector string. This way the string
> will always be read as unibyte string, avoiding all coding issues.
I think that hexadecimal notation would be quite more compact, without
a loss of generality and (probably unimportant) readability.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-26 22:53 ` David Kastrup
@ 2004-04-27 12:42 ` Andreas Schwab
2004-04-27 12:52 ` David Kastrup
0 siblings, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2004-04-27 12:42 UTC (permalink / raw)
Cc: Lars Brinkhoff, rms, emacs-devel
David Kastrup <dak@gnu.org> writes:
> I think that hexadecimal notation would be quite more compact, without
> a loss of generality and (probably unimportant) readability.
If you use hexadecimal notation then the reader will force the string to
multibyte, with octal notation it is forced to unibyte. The process of
converting a unibyte string to multibyte will change characters in the
range 0x80..0x9f. Maybe the bool vector reader should just force the
string back to unibyte.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-27 12:42 ` Andreas Schwab
@ 2004-04-27 12:52 ` David Kastrup
0 siblings, 0 replies; 14+ messages in thread
From: David Kastrup @ 2004-04-27 12:52 UTC (permalink / raw)
Cc: Lars Brinkhoff, rms, emacs-devel
Andreas Schwab <schwab@suse.de> writes:
> David Kastrup <dak@gnu.org> writes:
>
> > I think that hexadecimal notation would be quite more compact, without
> > a loss of generality and (probably unimportant) readability.
>
> If you use hexadecimal notation then the reader will force the string to
> multibyte, with octal notation it is forced to unibyte. The process of
> converting a unibyte string to multibyte will change characters in the
> range 0x80..0x9f. Maybe the bool vector reader should just force the
> string back to unibyte.
Ah, uh, ok. Just forget it, then. Looks like I did not know what I
was talking about. Not that this happens too rarely...
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-26 16:08 ` Andreas Schwab
2004-04-26 17:47 ` Lars Brinkhoff
@ 2004-04-27 16:28 ` Richard Stallman
2004-04-27 17:47 ` Andreas Schwab
1 sibling, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2004-04-27 16:28 UTC (permalink / raw)
Cc: lars, emacs-devel
The print syntax could use octal or hexadecimal escapes in the bit string.
That would be incompatible for some bool-vector values, wouldn't it?
The \ character could appear in a bool-vector with the current syntax.
To avoid misinterpreting some constants, I think we need to change the
syntax in a bigger way, to use a new syntax that would not be valid at
all under the old rules.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-26 22:01 ` Andreas Schwab
2004-04-26 22:53 ` David Kastrup
@ 2004-04-27 16:29 ` Richard Stallman
2004-04-27 17:54 ` Andreas Schwab
1 sibling, 1 reply; 14+ messages in thread
From: Richard Stallman @ 2004-04-27 16:29 UTC (permalink / raw)
Cc: lars, emacs-devel
I have now changed the print syntax to always use octal escapes for
non-ascii characters in the bool-vector string. This way the string will
always be read as unibyte string, avoiding all coding issues.
That was too hasty. As I mentioned earlier, this solution would cause
some previously-written bool-vectors to be read wrong.
If nobody has any previously-written bool-vectors, that incompatibility
does not matter, but are we confident of that? And is there a better way?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-27 16:28 ` Richard Stallman
@ 2004-04-27 17:47 ` Andreas Schwab
2004-04-29 10:43 ` Richard Stallman
0 siblings, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2004-04-27 17:47 UTC (permalink / raw)
Cc: lars, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> The print syntax could use octal or hexadecimal escapes in the bit string.
>
> That would be incompatible for some bool-vector values, wouldn't it?
> The \ character could appear in a bool-vector with the current syntax.
No, the print syntax already used backslash as escape within the string,
and the reader just uses the normal string parser.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-27 16:29 ` Richard Stallman
@ 2004-04-27 17:54 ` Andreas Schwab
0 siblings, 0 replies; 14+ messages in thread
From: Andreas Schwab @ 2004-04-27 17:54 UTC (permalink / raw)
Cc: lars, emacs-devel
Richard Stallman <rms@gnu.org> writes:
> I have now changed the print syntax to always use octal escapes for
> non-ascii characters in the bool-vector string. This way the string will
> always be read as unibyte string, avoiding all coding issues.
>
> That was too hasty. As I mentioned earlier, this solution would cause
> some previously-written bool-vectors to be read wrong.
The new syntax variant is completely backward and forward compatible.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Invalid read syntax for compiled bool vector
2004-04-27 17:47 ` Andreas Schwab
@ 2004-04-29 10:43 ` Richard Stallman
0 siblings, 0 replies; 14+ messages in thread
From: Richard Stallman @ 2004-04-29 10:43 UTC (permalink / raw)
Cc: lars, emacs-devel
No, the print syntax already used backslash as escape within the string,
and the reader just uses the normal string parser.
Ok, in that case I see no problem in your solution.
Thanks for taking care of the problem.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2004-04-29 10:43 UTC | newest]
Thread overview: 14+ 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
2004-04-26 14:10 ` Richard Stallman
2004-04-26 16:08 ` Andreas Schwab
2004-04-26 17:47 ` Lars Brinkhoff
2004-04-26 22:01 ` Andreas Schwab
2004-04-26 22:53 ` David Kastrup
2004-04-27 12:42 ` Andreas Schwab
2004-04-27 12:52 ` David Kastrup
2004-04-27 16:29 ` Richard Stallman
2004-04-27 17:54 ` Andreas Schwab
2004-04-27 16:28 ` Richard Stallman
2004-04-27 17:47 ` Andreas Schwab
2004-04-29 10:43 ` Richard Stallman
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.