generating symbols without with-standard-io-syntax

Bug #961350 reported by Pascal J. Bourguignon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IOLib
Confirmed
Undecided
Stelian Ionescu

Bug Description

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defun make-first-level-name (family type connect)
    (format-symbol :iolib.sockets "%~A-~A-~A-~A-~A" :make family type connect :socket)))

is wrong (alexandria is bugged). It should be:

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defun make-first-level-name (family type connect)
    (intern (with-standard-io-syntax (format nil "%~A-~A-~A-~A-~A" :make family type connect :socket))
             :iolib.sockets)))

Revision history for this message
Pascal J. Bourguignon (pjb-informatimago) wrote :

To see how wrong it is, just (setf *print-case* :downcase), load iolib, and try to create some socket.

Revision history for this message
Stelian Ionescu (sionescu) wrote :

Should be fixed, please test

Changed in iolib:
status: New → Confirmed
assignee: nobody → Stelian Ionescu (sionescu)
Revision history for this message
Attila Lendvai (attila-lendvai) wrote :

just to clarify, is it something that should be fixed in alexandria?

Revision history for this message
Pascal J. Bourguignon (pjb-informatimago) wrote : Re: [Bug 961350] Re: generating symbols without with-standard-io-syntax

On 22/03/2012, at 21:14, Attila Lendvai <email address hidden> wrote:

> just to clarify, is it something that should be fixed in alexandria?

Depends on the specifications of that function of alexandria. Pehaps they want to make symbols according to *print-case*?

--
__Pascal Bourguignon__

Revision history for this message
Stelian Ionescu (sionescu) wrote :

On Thu, 2012-03-22 at 23:06 +0000, Pascal J. Bourguignon wrote:
> On 22/03/2012, at 21:14, Attila Lendvai <email address hidden> wrote:
>
> > just to clarify, is it something that should be fixed in alexandria?
>
> Depends on the specifications of that function of alexandria. Pehaps
> they want to make symbols according to *print-case*?

My opinion is that format-symbol shuold respect *print-case* and that
normalizing the build environment should be done by ASDF: I'll try to
push the use of with-standard-io-syntax into ASDF itself

--
Stelian Ionescu a.k.a. fe[nl]ix
Quidquid latine dictum sit, altum videtur.
http://common-lisp.net/project/iolib

Revision history for this message
Attila Lendvai (attila-lendvai) wrote :

that makes sense, thanks for the clarification.

Revision history for this message
Pascal J. Bourguignon (pjb-informatimago) wrote :

Stelian Ionescu <email address hidden> writes:

> On Thu, 2012-03-22 at 23:06 +0000, Pascal J. Bourguignon wrote:
>> On 22/03/2012, at 21:14, Attila Lendvai <email address hidden> wrote:
>>
>> > just to clarify, is it something that should be fixed in alexandria?
>>
>> Depends on the specifications of that function of alexandria. Pehaps
>> they want to make symbols according to *print-case*?
>
> My opinion is that format-symbol shuold respect *print-case* and that
> normalizing the build environment should be done by ASDF: I'll try to
> push the use of with-standard-io-syntax into ASDF itself

I don't agree that normalizing the build environment should be done by
ASDF. More exactly, ASDF could wrap a with-syntax-io-syntax, but
libraries should not count on ASDF to do that, because they may (or
will) be compiled or loaded with other tools, where the environment may
have to be not-standard, to hook in code processing tools (eg. one could
set up a non-standard *readtable* to read and analyse a library).

Also, I was perhaps a little disingenious with alexandria:format-symbol.
It's purpose is to avoid problems with the readtable-case, by specifying
the format string as a symbol that is read with the same readtable as
the arguments. Didn't they think about *print-case*? Perhaps they did
and chosed to honor it as a feature. Perhaps they didn't think about it.

IMO, it would be more in line with the (alleged) purpose of
alexandria:format-symbol to wrap its call to format with
with-standard-io-syntax. (modulo the binding of *package*; in my
libraries, I have a wsiosbp macro:

    (defmacro wsiosbp (&body body)
      (let ((vpack (gensym)))
        `(let ((,vpack *package*))
           (with-standard-io-syntax
             (let ((*package* ,vpack))
               ,@body)))))

).

But my point is that it's a bug in iolib, however the environment is set
and however format-symbol is specified, not to control that the symbols
it makes and use match. (The sources of alexandria:format-symbol are
here to see what it does).

The error is to build a symbol name that may be in any case, and to
expect to read it two lines below with the standard (or active)
readtable-case.

Compare:

cl-user> (eq (alexandria:format-symbol *package* "~@{~A~}" 'make- 'stream '|-1|)
             'make-stream-1)
nil
cl-user> (eq (intern (format nil "~@{~A~}" (string 'make-) (string 'stream) (string '|-2|))
                     *package*)
             'make-stream-2)
t

cl-user> (eq (intern (concatenate 'string (string 'make-) (string 'stream) (string '|-3|))
                     *package*)
             'make-stream-3)
t

alexandria:format-symbol does something like:
  (format nil "~@{~A~}" 'make- 'stream '|-2|).

Notice that with a different readtable-case, format-symbol may or may
not give good results, while the two other forms will always give good
results.

--
__PASCAL Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.