using collections

Brian T Rice water at tunes.org
Sat May 3 16:44:26 PDT 2003


On Sat, 3 May 2003, Paul Dufresne wrote:

> Well, adding I guess adding a slot to root rather than on
> the lobby was a bad idea. But anyway, there seems to be a problem.
> ======================
> G:\slate>slate.fas
> Slate 1> 'src/init.slate' fileIn.
> Hi, there!
> Nil
> Slate 2> lobby addSlot: #x.
> <WM: Namespacetraits, lobby, prototypes, globals, Mixins, x,><WM: *LOBBY*,
> (trai
> ts lobby prototypes globals Mixins x)>
> Slate 3> x: Set clone.

Just as a small note, generally you should use #copy instead of #clone for
collections or any complex structure where one single object doesn't
encapsulate everything, since clone will re-use slot values identically,
whereas #copy can save you by overriding the default (which is to clone)
to also copy the array if it's writeable... Sharing a writeable array
between two collections could be messy later on.

> <WM: _traits, tally, array, hashBlock, equalsBlock, Iterator,>
> <WM: *PRIMITIVE-COLLECTION*, (traits tally array hashBlock equalsBlock
> Iterator)>
> Slate 4> x size.
> 0
> Slate 5> x capacity.
> 10
> Slate 6> x add: 5.
> 5
> Slate 7> x size.
> 1
> Slate 8> x capacity.
> 10
> Slate 9> x add: 3.
> 3
> Slate 10> x size.
> 2
> Slate 11> x add: 9.
>
> *** - AREF: index 10 for
> #(<WM: *PRIMITIVE-NIL*, (traits)> <WM: *PRIMITIVE-NIL*, (traits)> 3
>   <WM: *PRIMITIVE-NIL*, (traits)> <WM: *PRIMITIVE-NIL*, (traits)>
>   <WM: *PRIMITIVE-NIL*, (traits)> <WM: *PRIMITIVE-NIL*, (traits)>
>   <WM: *PRIMITIVE-NIL*, (traits)> 5 <WM: *PRIMITIVE-NIL*, (traits)>) is out
> of range

I'm seeing the same error in CMUCL and SBCL on Linux. I suspect that
hashing is broken, since it's used to determine the array index.

Yes, after some investigation, I see that #scanFor: for Sets sets a start
marker at the result of the hashBlock for the object in question, why by
default is the object's #hash result. I guess it's time to systematize the
hashing system, which has been rather ad hoc for too long.

> G:\slate>

So you're using CLISP on Windows.

> P.S. : I permit to write here quite fastly without checking much,
> since I believe this list need more traffic.

That's fine. I enjoy it.

-- 
Brian T. Rice
LOGOS Research and Development
mailto:water at tunes.org
http://tunes.org/~water/



More information about the Slate mailing list