From: Emre Sevinc
Subject: How to make HyperSpec's with-output-to-string ex. work?
Date: 
Message-ID: <87oe9cxiiy.fsf@ileriseviye.org>
HyperSpec has such an example:

(setq fstr (make-array '(0) :element-type 'base-char
                             :fill-pointer 0 :adjustable t)) =>  ""
(with-output-to-string (s fstr)
    (format s "here's some output")
    (input-stream-p s)) =>  false
 fstr =>  "here's some output"

I wanted to try it, after defininf a variable named fstr I typed
and I got an error message:

CL-USER> (setq fstr (make-array '(0) :element-type 'base-char
                             :fill-pointer 0 :adjustable t))
""

CL-USER> (with-output-to-string (s fstr)
    (format s "here's some output")
    (input-stream-p s))
; Evaluation aborted

The value ""
is not of type
  (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P)).
   [Condition of type TYPE-ERROR]

Restarts:
  0: [ABORT] Abort handling SLIME request.
  1: [DESTROY-THREAD] Destroy this thread (28169)

Backtrace:
  0: (SB-IMPL::MAKE-FILL-POINTER-OUTPUT-STREAM "")
  1: (#:EVAL-TMPFUN-4600)
  2: (SB-INT:EVAL-IN-LEXENV (WITH-OUTPUT-TO-STRING (S FSTR) 
                (FORMAT S "here's some output") (INPUT-STREAM-P S))


Why couldn't I get a string filled with Lisp's output?


-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr

From: Pascal Bourguignon
Subject: Re: How to make HyperSpec's with-output-to-string ex. work?
Date: 
Message-ID: <873bqom92r.fsf@thalassa.informatimago.com>
Emre Sevinc <·····@bilgi.edu.tr> writes:

> HyperSpec has such an example:
>
> (setq fstr (make-array '(0) :element-type 'base-char
>                              :fill-pointer 0 :adjustable t)) =>  ""
> (with-output-to-string (s fstr)
>     (format s "here's some output")
>     (input-stream-p s)) =>  false
>  fstr =>  "here's some output"
>
> I wanted to try it, after defininf a variable named fstr I typed
> and I got an error message:
>
> CL-USER> (setq fstr (make-array '(0) :element-type 'base-char
>                              :fill-pointer 0 :adjustable t))
> ""
>
> CL-USER> (with-output-to-string (s fstr)
>     (format s "here's some output")
>     (input-stream-p s))
> ; Evaluation aborted
>
> The value ""
> is not of type
>   (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P)).
>    [Condition of type TYPE-ERROR]

Bad implementation.  Change implementation.  With clisp:

[14]> (setq fstr (make-array '(0) :element-type 'base-char
                             :fill-pointer 0 :adjustable t))
""
[15]> (with-output-to-string (s fstr)
    (format s "here's some output")
    (input-stream-p s))
NIL
[16]> fstr
"here's some output"
[17]> 

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

This is a signature virus.  Add me to your signature and help me to live
From: Emre Sevinc
Subject: Re: How to make HyperSpec's with-output-to-string ex. work?
Date: 
Message-ID: <87k6k0xcub.fsf@ileriseviye.org>
Pascal Bourguignon <···@informatimago.com> writes:

> Emre Sevinc <·····@bilgi.edu.tr> writes:
>
>> CL-USER> (setq fstr (make-array '(0) :element-type 'base-char
>>                              :fill-pointer 0 :adjustable t))
>> ""
>>
>> CL-USER> (with-output-to-string (s fstr)
>>     (format s "here's some output")
>>     (input-stream-p s))
>> ; Evaluation aborted
>>
>> The value ""
>> is not of type
>>   (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P)).
>>    [Condition of type TYPE-ERROR]
>
> Bad implementation.  Change implementation.  With clisp:
>
> [14]> (setq fstr (make-array '(0) :element-type 'base-char
>                              :fill-pointer 0 :adjustable t))
> ""
> [15]> (with-output-to-string (s fstr)
>     (format s "here's some output")
>     (input-stream-p s))
> NIL
> [16]> fstr
> "here's some output"
> [17]> 

Maybe I should update my SBCL, it is version 0.8.20.5
to see if they have corrected the problem and if I still
get the same error then maybe I should report this as a bug.

(some time passes...)

Well, it seems like sbcl package from unstable Debian
repository is buggy (/usr/lib/common-lisp/bin/sbcl.sh loading and dumping clc. 
step waits forever) :( 

I had to install sbcl/testing which is gives me an older 
sbcl (v. 0.8.16) but this time, without the error (now should I
 be happy to have an older version without that error?):

CL-USER> (setq fstr (make-array '(0) :element-type 'base-char 
                                     :fill-pointer 0 :adjustable t))
""
CL-USER> (with-output-to-string (s fstr) 
           (format s "here's some output") 
           (input-stream-p s))
NIL
CL-USER> fstr
"here's some output"
CL-USER> 



-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr
From: Kalle Olavi Niemitalo
Subject: Re: How to make HyperSpec's with-output-to-string ex. work?
Date: 
Message-ID: <87fyumls27.fsf@Astalo.kon.iki.fi>
Pascal Bourguignon <···@informatimago.com> writes:

> Emre Sevinc <·····@bilgi.edu.tr> writes:
>> The value ""
>> is not of type
>>   (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P)).
>>    [Condition of type TYPE-ERROR]
>
> Bad implementation.

SBCL 0.8.16.22 added a "FIXME" about this bug near the definition
of STRING-WITH-FILL-POINTER in SYS:SRC;CODE;STREAM.LISP.
From: Christophe Rhodes
Subject: Re: How to make HyperSpec's with-output-to-string ex. work?
Date: 
Message-ID: <sq7jfzxfek.fsf@cam.ac.uk>
Emre Sevinc <·····@bilgi.edu.tr> writes:

> CL-USER> (setq fstr (make-array '(0) :element-type 'base-char
>                              :fill-pointer 0 :adjustable t))
> ""
>
> CL-USER> (with-output-to-string (s fstr)
>     (format s "here's some output")
>     (input-stream-p s))
> ; Evaluation aborted
>
> The value ""
> is not of type
>   (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P)).
>
> Why couldn't I get a string filled with Lisp's output?

This is a known bug in SBCL, as fallout from the implementation of
full Unicode support.  A workaround for now is to use
  :element-type 'character 
instead.

Christophe