PATCH Re: [rucksack-devel] indexing issue?

Cyrus Harmon ch-rucksack at bobobeach.com
Wed Jan 10 21:13:25 UTC 2007


Ok, I think I've figured out what's wrong with unique slots:

--- mop.lisp	28 Nov 2006 15:25:57 -0800	1.11
+++ mop.lisp	10 Jan 2007 13:12:19 -0800	
@@ -250,6 +250,17 @@
               (setf (slot-value effective-slotdef 'index)
                     (slot-index (car index-slotdefs))))))

+    ;; If exactly one direct slot is unique, then the effective one is
+    ;; too. If more then one is unique, signal an error.
+    (let ((unique-slotdefs (remove-if-not #'slot-unique persistent- 
slotdefs)))
+      (cond ((cdr unique-slotdefs)
+             (error "Multiple uniques for slot ~S in ~S:~% ~{~S~^, ~}."
+                    slot-name class
+                    (mapcar #'slot-unique unique-slotdefs)))
+            (unique-slotdefs
+             (setf (slot-value effective-slotdef 'unique)
+                   (slot-unique (car unique-slotdefs))))))
+
      ;; Return the effective slot definition.
      effective-slotdef))

I think c-e-s-d needs the previous patch in order to set the  
effective-slot-definition's unique slot properly. I'm not sure it's  
appropriate to signal an error, but it seems better than allowing  
both :unique t and unique :no-error to be specified.

Cyrus


On Jan 9, 2007, at 11:43 PM, Cyrus Harmon wrote:

>
> On Nov 30, 2006, at 10:43 AM, Arthur Lemmens wrote:
>
>> Cyrus Harmon wrote:
>>
>>> What is the intended behavior of a unique slot?
>>
>> 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).
>>
>>> I'm able to make-instance new instances of a persistent class with
>>> a duplicate slot value
>>
>> Yes, I think that Rucksack doesn't check for this at the moment.
>> But it should have signalled an error, I think.
>>
>>> which seems fine
>>
>> I don't think so ;-)
>
> [some months pass...] so, yes, it seems like this should signal an  
> error. and it looks like there's code in there to do that, but yet  
> it doesn't seem to signal an error. Any idea why not?
>
> Thanks,
>
> Cyrus
>
> _______________________________________________
> rucksack-devel mailing list
> rucksack-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/rucksack-devel




More information about the rucksack-devel mailing list