[gnu.emacs.bug] nulls in strings passed to format

cyclops%TAMUNIX.BITNET@MITVMA.MIT.EDU (Glenn Vanderburg) (10/01/88)

I have a question about emacs lisp.  The format function is not
behaving the way I expect it to.  The reason I'm writing is that it
behaves precisely the way I *want* it to, but before I write code that
depends on this unexpected behavior, I'd like to know if this is a
feature or a bug.

As I understand it, strings in gnu emacs can contain nulls.  This fits
the facts: (princ "a\000a") prints "a
appears to believe otherwise: (princ (format "a%ca%c\000%ca" ?b ?b
?b)) prints "abab", and (princ (format "a%sa" "b\000b")) prints "aba".
A null in any string passed as an argument to format terminates the
string.

Now, this is not surprising, since format is written in C.  I would
personally like for it to stay this way (at least for the application
I'm writing now) but I'd like to know if this is considered a bug,
because I don't want to write code that depends on a feature which may
be "fixed" soon.

Regards,
Glenn Vanderburg

shap@polya.Stanford.EDU (Jonathan S. Shapiro) (10/01/88)

If you will forgive me for interjecting an *opinion*, it seems to me
that relying on an aspect of the behavior of FORMAT that is
implementation-specific is at best a risky proposition.  To the best
of my knowledge, LISPs in general don't do anything special about
NUL's, and in my opinion it would be a mistake to encourage EMACS-LISP
to commit in this direction.

In fact, I consider this aspect of the behavior of FORMAT to be a
*bug*.  It is not, however, a bug that I worry about - i.e. I don't
care if it ggets fixed or not.

Jon