[postmodern-devel] Can't redefine slots as columns - why?
Lucas Hope
lucas.r.hope at gmail.com
Tue Mar 10 20:00:22 UTC 2009
Hi Marijn,
It seems to work fine. If it was me, I'd remove the test, but
wouldn't bother creating a new release just for this.
Thanks for your work. :-)
-Luke
On Wed, Mar 11, 2009 at 6:13 AM, Marijn Haverbeke <marijnh at gmail.com> wrote:
> Hi Luke,
>
> I have to admit that I don't really remember how direct slots and
> effective slots are supposed to work. If everything works as intended
> for you, I'll drop the test and allow slots from superclasses to be
> defined as column slots.
>
> Best,
> Marijn
>
> On Tue, Mar 10, 2009 at 8:00 PM, Lucas Hope <lucas.r.hope at gmail.com> wrote:
>> Hi Marijn,
>>
>> I guess I suffered from working 12 hours and then emailing you.
>>
>> My little example had a fatal flaw: I hadn't defined an :initarg for
>> radius! Some preliminary (re-)testing indicates that your initial
>> fix/alteration works.
>>
>> Thanks for your help!
>>
>> -Luke
>>
>>
>> On Tue, Mar 10, 2009 at 9:51 PM, Marijn Haverbeke <marijnh at gmail.com> wrote:
>>> Ah, you are right. If the slot object has already been instantiated as
>>> a regular slot, I don't know of any safe, portable way to make it a
>>> column slot. If you can think of a hack to make this work, let me
>>> know. But for now, you'll have to solve this in some other way.
>>>
>>> Best,
>>> Marijn
>>>
>>>
>>> On Tue, Mar 10, 2009 at 10:10 AM, Lucas Hope <lucas.r.hope at gmail.com> wrote:
>>>> Hi Marijn,
>>>>
>>>> I stubbed out the form and the dao-circle was successfully compiled (of course).
>>>>
>>>> However the example circle I tried to make did not have its slot value
>>>> set. I understand (I think) what you were trying to do with the
>>>> *direct-column-slot* special variable, but maybe in this case (on
>>>> Allegro CL, btw), while the effective-slot-definition-class works
>>>> correctly (indicated by the correct CREATE TABLE below), the actual
>>>> effective-column-slot object is instantiated OUTSIDE the scope of the
>>>> binding in compute-effective-slot-definitio which sets
>>>> *direct-column-slot* to non-nil.
>>>>
>>>> There's no reason for the lisp implementation to instantiate the class
>>>> returned by effective-column-slot immediately, as far as I can tell.
>>>>
>>>> (dao-table-definition 'dao-circle) ;; success!
>>>> "CREATE TABLE dao_circle (radius REAL NOT NULL)"
>>>>
>>>> (setf circle (make-instance 'dao-circle :radius 5.0))
>>>>
>>>> (slot-boundp circle 'radius)
>>>> => NIL ;; fail. :(
>>>>
>>>> -Luke
>>>>
>>>> On Tue, Mar 10, 2009 at 6:19 PM, Marijn Haverbeke <marijnh at gmail.com> wrote:
>>>>> Hello Luke,
>>>>>
>>>>> I think (though I'm never entirely sure with this MOP stuff) that that
>>>>> error is only there becuase I hadn't thought of the way you are trying
>>>>> to use this metaclass, and assumed redefining a slot as a column was
>>>>> always an accident. Could you try killing the WHEN-form on line 97 of
>>>>> postmodern/table.lisp, doing what you're trying to do, and reporting
>>>>> back whether it works as hoped?
>>>>>
>>>>> Best,
>>>>> Marijn
>>>>>
>>>>>
>>>>> On Tue, Mar 10, 2009 at 1:11 AM, Lucas Hope <lucas.r.hope at gmail.com> wrote:
>>>>>> Hi there,
>>>>>>
>>>>>> I am just getting my feet wet with postmodern. It looks like I will
>>>>>> be doing some heavy development with it for the next couple of weeks.
>>>>>> Wish me luck!
>>>>>>
>>>>>> My (first?) issue is that I want to do something similar to the
>>>>>> following example code. Here CIRCLE is an in-memory implementation of
>>>>>> a circle, and it is desired to create a DAO object which moves storage
>>>>>> to a postgres backend. (We have lots of circles...)
>>>>>>
>>>>>> Pretend CIRCLE has a host of useful functionality attached and I can't
>>>>>> just point all the defmethods to DAO-CIRCLE.
>>>>>>
>>>>>> (defclass SHAPE () ())
>>>>>>
>>>>>> (defclass CIRCLE (SHAPE)
>>>>>> (radius))
>>>>>>
>>>>>> (defclass DAO-CIRCLE (CIRCLE)
>>>>>> ((radius :col-type real))
>>>>>> (:metaclass dao-class))
>>>>>>
>>>>>> (dao-table-definition 'dao-circle)
>>>>>> => ERROR: Slot RADIUS in class #<DAO-CLASS DAO-CIRCLE> is both a
>>>>>> column slot and a regular slot.
>>>>>>
>>>>>> Why doesn't this work, and how can I make it work? It seems like this
>>>>>> is useful functionality to have. I want the DAO-CIRCLE's radius to be
>>>>>> a column slot.
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> -Luke
>>
>> _______________________________________________
>> postmodern-devel mailing list
>> postmodern-devel at common-lisp.net
>> http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
>>
>
> _______________________________________________
> postmodern-devel mailing list
> postmodern-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/postmodern-devel
>
More information about the postmodern-devel
mailing list