Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

remove-if and fill-pointer

2 views
Skip to first unread message

joa...@arti.vub.ac.be

unread,
Nov 29, 2002, 10:23:54 AM11/29/02
to

Hello,

I noticed that when using remove,remove-if etc. functions on an
adjustable array or an array with a fill-pointer, the result is an
array _without_ a fill-pointer and that is not adjustable.

Why is this?

And is there a way to remove elements from (the interior of a)
fill-pointer array and still have a fill-pointer array as the result
without defining a new fill-pointer-remove-if function or redefining
remove-if etc. ?

Thanks, Joachim.

Paul F. Dietz

unread,
Nov 29, 2002, 10:32:56 AM11/29/02
to joa...@arti.vub.ac.be
joa...@arti.vub.ac.be wrote:
> Hello,
>
> I noticed that when using remove,remove-if etc. functions on an
> adjustable array or an array with a fill-pointer, the result is an
> array _without_ a fill-pointer and that is not adjustable.
>
> Why is this?

Because the standard requires it:

Section 17.1:

"A sequence function is a function defined by this specification or
added as an extension by the implementation that operates on one or
more sequences. Whenever a sequence function must construct and return
a new vector, it always returns a simple vector. Similarly, any strings
constructed will be simple strings."

Paul

joa...@arti.vub.ac.be

unread,
Nov 29, 2002, 11:02:40 AM11/29/02
to
"Paul F. Dietz" <di...@dls.net> writes:

> joa...@arti.vub.ac.be wrote:
> > Why is this?
>

> Because the standard requires it (Section 17.1)

ok, this is rather uncounterable :-)

but what about my second question? Maybe I should rephrase it:

"What are fill-pointer arrays for if you can only implement a stack
with them and not e.g. remove elements?"

Joachim.

Paul F. Dietz

unread,
Nov 29, 2002, 11:07:13 AM11/29/02
to joa...@arti.vub.ac.be
I wrote:

>> I noticed that when using remove,remove-if etc. functions on an
>> adjustable array or an array with a fill-pointer, the result is an
>> array _without_ a fill-pointer and that is not adjustable.
>>
>> Why is this?
>
>
> Because the standard requires it:

Atually, this isn't right. It's possible that arrays with fill
pointers or adjustable arrays are also simple, but they typically aren't
in Lisps implemented on stock hardware.

Paul

Erik Naggum

unread,
Nov 29, 2002, 1:41:42 PM11/29/02
to
* joa...@arti.vub.ac.be

| I noticed that when using remove,remove-if etc. functions on an
| adjustable array or an array with a fill-pointer, the result is an array
| _without_ a fill-pointer and that is not adjustable.
|
| Why is this?

Because you ask for a new sequence with the `remove´ version.

Perhaps you should investigate the `delete´ versions?

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.

Tim Bradshaw

unread,
Nov 29, 2002, 1:39:07 PM11/29/02
to
* joachim wrote:

> "What are fill-pointer arrays for if you can only implement a stack
> with them and not e.g. remove elements?"

Well, the classic answer would be some kind of buffer object. Say I'm
reading chunks of data into a buffer, and I don't know how big they
are, but I know there's some maximum size (or maybe, if the size is
bigger than I've allowed for I'm willing to use ADJUST-ARRAY to
allocate a bigger buffer). I want to reuse the buffer, but I don't
want to have to keep passing around the information that only the
first n elements of this thing actually have useful data. So I use a
fill pointer to tell me that.

However, going back to your original question, I think you may be
confused about what REMOVE &co do - they are nondestructive functions,
so they aren't allowed to alter the arrays that are their arguments.
DELETE &co are allowed to be destructive, but don't have to be so.

--tim

0 new messages