From: Jimka
Subject: The value "" is not of type (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P))
Date: 
Message-ID: <1156590147.998579.311440@m79g2000cwm.googlegroups.com>
Can someone please explain to me the meaning of this error.
When i type in the example from the hyperspec into sbcl i get an
error rather than the predicted result.

http://www.lisp.org/HyperSpec/Body/mac_with-output-to-string.html#with-output-to-string

(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))

Rather than with-output-to-string returning nil, the following error
occurs.
The value "" is not of type (AND (VECTOR CHARACTER) (SATISFIES
ARRAY-HAS-FILL-POINTER-P)).
   [Condition of type TYPE-ERROR]

From: Christopher Brown
Subject: Re: The value "" is not of type (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P))
Date: 
Message-ID: <1156594047.469622.237240@h48g2000cwc.googlegroups.com>
Your problem looks a lot like mine and I imagine someone who knows a
bunch more will probably jump in to correct me.  It appears that,
related to unicode support, base-char and character are not
interchangeable as types.  The example makes an array of 'base-char but
with-output to string expects them to be 'character.

Either of the following seems to work:

1) Make (with-output-to-string ...) use 'base-char:
(let ((fstr
   (with-output-to-string (s nil :element-type 'base-char)
      (format s "here's some output")
      (input-stream-p s))))
fstr)

2) Make your original string of type (vector 'character)
(setq fstr (make-array '(0) :element-type 'character
                             :fill-pointer 0 :adjustable t))
(with-output-to-string (s fstr)
    (format s "here's some output")
    (input-stream-p s))

The hyperspec alludes to this in the base-char topic:  In the first
implementation, the type
base-char is equivalent to the type character: there is only one kind
of string. In the second implementation, the
base characters might be those characters that could be stored in a
string of characters having 8-bit encodings.

(P.S. Don't listen to me... I'm new too)

Cheers,
Christopher

Jimka wrote:
> Can someone please explain to me the meaning of this error.
> When i type in the example from the hyperspec into sbcl i get an
> error rather than the predicted result.
>
> http://www.lisp.org/HyperSpec/Body/mac_with-output-to-string.html#with-output-to-string
>
> (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))
>
> Rather than with-output-to-string returning nil, the following error
> occurs.
> The value "" is not of type (AND (VECTOR CHARACTER) (SATISFIES
> ARRAY-HAS-FILL-POINTER-P)).
>    [Condition of type TYPE-ERROR]
From: Jimka
Subject: Re: The value "" is not of type (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P))
Date: 
Message-ID: <1156594754.098931.67160@75g2000cwc.googlegroups.com>
Thanks Christopher, that works for me as well.


Christopher Brown wrote:
> Your problem looks a lot like mine and I imagine someone who knows a
> bunch more will probably jump in to correct me.  It appears that,
> related to unicode support, base-char and character are not
> interchangeable as types.  The example makes an array of 'base-char but
> with-output to string expects them to be 'character.
>
> Either of the following seems to work:
>
> 1) Make (with-output-to-string ...) use 'base-char:
> (let ((fstr
>    (with-output-to-string (s nil :element-type 'base-char)
>       (format s "here's some output")
>       (input-stream-p s))))
> fstr)
>
> 2) Make your original string of type (vector 'character)
> (setq fstr (make-array '(0) :element-type 'character
>                              :fill-pointer 0 :adjustable t))
> (with-output-to-string (s fstr)
>     (format s "here's some output")
>     (input-stream-p s))
>
> The hyperspec alludes to this in the base-char topic:  In the first
> implementation, the type
> base-char is equivalent to the type character: there is only one kind
> of string. In the second implementation, the
> base characters might be those characters that could be stored in a
> string of characters having 8-bit encodings.
>
> (P.S. Don't listen to me... I'm new too)
>
> Cheers,
> Christopher
>
> Jimka wrote:
> > Can someone please explain to me the meaning of this error.
> > When i type in the example from the hyperspec into sbcl i get an
> > error rather than the predicted result.
> >
> > http://www.lisp.org/HyperSpec/Body/mac_with-output-to-string.html#with-output-to-string
> >
> > (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))
> >
> > Rather than with-output-to-string returning nil, the following error
> > occurs.
> > The value "" is not of type (AND (VECTOR CHARACTER) (SATISFIES
> > ARRAY-HAS-FILL-POINTER-P)).
> >    [Condition of type TYPE-ERROR]
From: Thomas F. Burdick
Subject: Re: The value "" is not of type (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P))
Date: 
Message-ID: <xcv7j0upovk.fsf@conquest.OCF.Berkeley.EDU>
"Christopher Brown" <··········@gmail.com> writes:

> Your problem looks a lot like mine and I imagine someone who knows a
> bunch more will probably jump in to correct me.  It appears that,
> related to unicode support, base-char and character are not
> interchangeable as types.  The example makes an array of 'base-char but
> with-output to string expects them to be 'character.

That's exactly correct.  I think the best explanation of the issue at
hand is slide 18 of this presentation:
http://www.doc.gold.ac.uk/~mas01cr/talks/2005-04-24%20Amsterdam/presentation.pdf

It shows pictures of, in order:

  (vector character)
  (vector base-char)
  (vector character)
  (vector character)
  (vector base-char)
From: Rob Warnock
Subject: Re: The value "" is not of type (AND (VECTOR CHARACTER) (SATISFIES ARRAY-HAS-FILL-POINTER-P))
Date: 
Message-ID: <dvCdnWpEedxap23ZnZ2dnUVZ_o-dnZ2d@speakeasy.net>
Jimka <·····@rdrop.com> wrote:
+---------------
| Can someone please explain to me the meaning of this error.
| When i type in the example from the hyperspec into sbcl i get an
| error rather than the predicted result.
| (setq fstr (make-array '(0) :element-type 'base-char
|                              :fill-pointer 0 :adjustable t))
+---------------

[Note: You really should declare your variables before using them...]

+---------------
| (with-output-to-string (s fstr)
|     (format s "here's some output")
|     (input-stream-p s))
| 
| Rather than with-output-to-string returning nil, the following error
| occurs.
| The value "" is not of type (AND (VECTOR CHARACTER) (SATISFIES
| ARRAY-HAS-FILL-POINTER-P)).
|    [Condition of type TYPE-ERROR]
+---------------

That works fine in both CMUCL & CLISP.


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607