From: Francogrex
Subject: vector-push-extend
Date: 
Message-ID: <60ee0976-6bc8-43ce-8377-d8fa95ac6ff8@f19g2000yqo.googlegroups.com>
(let ((x (make-array 5 :fill-pointer 0)))
  (dotimes (i 10)
    (vector-push-extend (random 1.0) x)) x)

Result in SBCL:
#(0.5099975 0.008324027 0.001173377 0.77798724 0.24247074 0.97725177
  0.067973495 0.76105237 0.06009364 0.3982551)

In another implementation:
> ERROR: The index, 5, too large.

Is this a normal result in the other implementation?

From: Pascal J. Bourguignon
Subject: Re: vector-push-extend
Date: 
Message-ID: <873acndspf.fsf@informatimago.com>
Francogrex <······@grex.org> writes:

> (let ((x (make-array 5 :fill-pointer 0)))
>   (dotimes (i 10)
>     (vector-push-extend (random 1.0) x)) x)
>
> Result in SBCL:
> #(0.5099975 0.008324027 0.001173377 0.77798724 0.24247074 0.97725177
>   0.067973495 0.76105237 0.06009364 0.3982551)
>
> In another implementation:
>> ERROR: The index, 5, too large.
>
> Is this a normal result in the other implementation?

Yes.  Try:

(let ((size 10))
  (let ((x (make-array size :fill-pointer 0)))
    (dotimes (i size)
      (vector-push-extend (random 1.0) x)) x))

(or have a look at adjustable arrays).
-- 
__Pascal Bourguignon__
http://www.informatimago.com
From: Francogrex
Subject: Re: vector-push-extend
Date: 
Message-ID: <7115f2a5-7554-4225-b736-c813064c757f@3g2000yqk.googlegroups.com>
On Apr 5, 5:29 pm, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> Francogrex <······@grex.org> writes:
> > (let ((x (make-array 5 :fill-pointer 0)))
> >   (dotimes (i 10)
> >     (vector-push-extend (random 1.0) x)) x)
>
> > Result in SBCL:
> > #(0.5099975 0.008324027 0.001173377 0.77798724 0.24247074 0.97725177
> >   0.067973495 0.76105237 0.06009364 0.3982551)
>
> > In another implementation:
> >> ERROR: The index, 5, too large.
>
> > Is this a normal result in the other implementation?
>
> Yes.  Try:
>
> (let ((size 10))
>   (let ((x (make-array size :fill-pointer 0)))
>     (dotimes (i size)
>       (vector-push-extend (random 1.0) x)) x))
>
> (or have a look at adjustable arrays).
> --
> __Pascal Bourguignon__http://www.informatimago.com

That works of course because size is the same; but your hint to
adjustable solved my original request which was the *extension*:

(let ((x (make-array 5 :fill-pointer 0 :adjustable t)))
  (dotimes (i 10)
    (vector-push-extend (random 1.0) x)) x)

works in the other implementation. It's funny though that SBCL seems
to have :adjustable t always turned on by default.
From: Tamas K Papp
Subject: Re: vector-push-extend
Date: 
Message-ID: <73s38rF102tgjU1@mid.individual.net>
On Sun, 05 Apr 2009 08:43:48 -0700, Francogrex wrote:

> On Apr 5, 5:29 pm, ····@informatimago.com (Pascal J. Bourguignon) wrote:
>> Francogrex <······@grex.org> writes:
>> > (let ((x (make-array 5 :fill-pointer 0)))
>> >   (dotimes (i 10)
>> >     (vector-push-extend (random 1.0) x)) x)
>>
>> > Result in SBCL:
>> > #(0.5099975 0.008324027 0.001173377 0.77798724 0.24247074 0.97725177
>> >   0.067973495 0.76105237 0.06009364 0.3982551)
>>
>> > In another implementation:
>> >> ERROR: The index, 5, too large.
>>
>> > Is this a normal result in the other implementation?
>>
>> Yes.  Try:
>>
>> (let ((size 10))
>>   (let ((x (make-array size :fill-pointer 0)))
>>     (dotimes (i size)
>>       (vector-push-extend (random 1.0) x)) x))
>>
>> (or have a look at adjustable arrays). --
>> __Pascal Bourguignon__http://www.informatimago.com
> 
> That works of course because size is the same; but your hint to
> adjustable solved my original request which was the *extension*:
> 
> (let ((x (make-array 5 :fill-pointer 0 :adjustable t)))
>   (dotimes (i 10)
>     (vector-push-extend (random 1.0) x)) x)
> 
> works in the other implementation. It's funny though that SBCL seems to
> have :adjustable t always turned on by default.

Why is it funny?  The spec says:

If adjustable is non-nil, the array is expressly adjustable (and so
actually adjustable); otherwise, the array is not expressly adjustable
(and it is implementation-dependent whether the array is actually
adjustable).

So the implementation is allowed to do as it pleases, if other factors
do not constrain its choice.  AFAIK SBCL gives you adjustable arrays
is you give a fill pointer

CL-USER> (adjustable-array-p (make-array 5))
NIL
CL-USER> (adjustable-array-p (make-array 5 :fill-pointer 0))
T

Sometimes I think that Lisp arrays are a bit complicated, a lot of
different things were pushed into the concept of an array.

Tamas
From: Francogrex
Subject: Re: vector-push-extend
Date: 
Message-ID: <4a7e6bec-3151-4984-b8bd-91c744f0c5f2@c36g2000yqn.googlegroups.com>
On Apr 5, 6:06 pm, Tamas K Papp <······@gmail.com> wrote:
> CL-USER> (adjustable-array-p (make-array 5))
> NIL
> CL-USER> (adjustable-array-p (make-array 5 :fill-pointer 0))
> T

So in SBCL this should result in nil?
(adjustable-array-p (make-array 5 :fill-pointer 0 :adjustable nil))
From: Tamas K Papp
Subject: Re: vector-push-extend
Date: 
Message-ID: <73sk6sF10g3jbU1@mid.individual.net>
On Sun, 05 Apr 2009 13:19:43 -0700, Francogrex wrote:

> On Apr 5, 6:06 pm, Tamas K Papp <······@gmail.com> wrote:
>> CL-USER> (adjustable-array-p (make-array 5)) NIL
>> CL-USER> (adjustable-array-p (make-array 5 :fill-pointer 0)) T
> 
> So in SBCL this should result in nil? (adjustable-array-p (make-array 5
> :fill-pointer 0 :adjustable nil))

I don't know why you think that.  From the spec for make-array:

"There is no specified way to create an array for which
adjustable-array-p definitely returns false."

Also, if you try that in SBCL, it returns t.  Read the spec carefully,
it is worth it, CL's array concept is a bit convoluted.

Tamas