[rucksack-devel] indexing issue?

Arthur Lemmens alemmens at xs4all.nl
Thu Nov 30 19:21:08 UTC 2006


Cyrus Harmon wrote:

>> If a class has a unique slot, you (the programmer) promise that there
>> won't be two instances of that class which have a 'similar' value
>> for that slot.  The definition of 'similar' depends on the kind of
>> index you create (see the predefined index specs in index.lisp for
>> some examples).
>
> Ok, I'd feel better if the system were to promise me that it were not
> to allow such a scenario.

Yes, I agree.

> I don't suppose there is any notion of a multi-slot index or a multi-slot
> uniqueness constraint?

Not at the moment, but I think it would be a useful addition to Rucksack.
So if you have a nice design for this...

> Also, presumably this uniqueness constraint is per-rucksack, not
> globally for all instances of this class.

Yes.

> I wonder how subclassing affects this...

I don't think I documented this, and I must admit I can't tell you
 from the top of my head.  But have a look at the definition
of RUCKSACK-MAYBE-INDEX-CHANGED-SLOT and the INCLUDE-SUPERCLASSES
argument for RUCKSACK-SLOT-INDEX.

>> All class and slot indexes are automatically added to the root set.
>> So if you create an instance of a class that has an indexed slot,
>> that instance will automatically be reachable from the roots and it
>> won't be removed by Rucksack's garbage collector.
>
> Hmm... Ok, this I still don't quite get. when I make-instance a
> persistent object, I should then be able to map-rucksack-roots to get
> this instance?

No.  But if you MAKE-INSTANCE a persistent object that has a slot
or a class index (or, to be more precise, if you MAKE-INSTANCE a
persistent object that is added to a slot or class index), you can
be sure that Rucksack's garbage collector won't remove that object
behind your back.

You're not supposed to use MAP-RUCKSACK-ROOTS to find such an object.
But you indexed it, right?  So you can use the indexes to find it.

> On a related note, how do I go about explicitly deleting objects?

Actually, that's the wrong question ;-)

You don't explicitly delete an object, the garbage collector will
delete it for you if it can't be reached from the root set.  Just
like in normal Lisp...

If you really want to, it shouldn't be too difficult to delete an
object from all slot indexes where it occurs.  But you should probably
ask yourself if you really need this before you do it.

> I notice that delete-rucksack-root is not exported. is this
> intentional?

Yes.  I don't expect that a normal Rucksack user would need this
function.

Arthur




More information about the rucksack-devel mailing list