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

fill-pointer/compilation question

0 views
Skip to first unread message

Norman Werner

unread,
Sep 14, 2003, 8:31:04 AM9/14/03
to
Hello,

I do create an vector with a fill pointer and everything is fine.

(setq *test* (make-array 0 :element-type 'list :fill-pointer t :adjustable t))
=> #()
(array-has-fill-pointer-p *test*)
=> T

But after compiling a file with: (setq user::*test* '#.user::*test*)
to save this vector in a file and loading this file again to restore
the vector

(array-has-fill-pointer-p *test*)
=> NIL

And of course this results in errors later on.


Is it me or is it the implementation doing wrong? Is it possible to
attach a fill-pointer to a vector after creation (I didn't found
anything)? I don't rely on fill-pointers - I think I can make the code
working without. But anyway this puzzles me.


Norman
--
One Language to rule them all, One Language to find them, One Language
to bring them all and in the darkness bind them in the Land of Mordor
where the Shadows lie.

Norman Werner (Zi. 307)
J. G. Nathusius Ring 7 (WH6)
39106 Magdeburg
norman...@student.uni-magdeburg.de

Kalle Olavi Niemitalo

unread,
Sep 14, 2003, 7:18:40 AM9/14/03
to
Norman Werner <norman...@student.uni-magdeburg.de> writes:

> But after compiling a file with: (setq user::*test*
> '#.user::*test*) to save this vector in a file and loading this
> file again to restore the vector
>
> (array-has-fill-pointer-p *test*)
> => NIL

The file compiler is permitted to remove fill pointers from
arrays. See CLHS sections 3.2.4.2.2 and 3.2.4.4.

Perhaps you could instead construct the vector at load time, with
something like:

(setq user::*test*
(make-array '#.(array-dimensions user::*test*)
:initial-contents '#.user::*test*
:fill-pointer '#.(fill-pointer user::*test*)))

This code itself is not portable, because the file compiler can
also truncate the array at the fill pointer and then it won't have
enough elements for :initial-contents.

Norman Werner

unread,
Sep 14, 2003, 1:26:37 PM9/14/03
to
Kalle Olavi Niemitalo <k...@iki.fi> skribis:

Thanks for the clarification.
I had afterwards a hard but fair argument with my
clhs and I think we can still be friends.

This:
(setq user::*test
(make-array
'#.(fill-pointer user::*test*)
:adjustable t
:fill-pointer t
:initial-contents '#.user::*test*))

Now _seems_ to work.

0 new messages