From penguin at ocean.vvo.ru Fri Feb 16 02:22:20 2007 From: penguin at ocean.vvo.ru (Igor Plekhov) Date: Fri, 16 Feb 2007 12:22:20 +1000 Subject: [closer-devel] remove a layered method Message-ID: <20070216022220.GU344@ocean.vvo.ru> How can I remove a layered method (previously defined with define-layered-method)? -- Registered Linux User #124759 From penguin at ocean.vvo.ru Fri Feb 16 04:37:17 2007 From: penguin at ocean.vvo.ru (Igor Plekhov) Date: Fri, 16 Feb 2007 14:37:17 +1000 Subject: [closer-devel] with-active-layers Message-ID: <20070216043717.GV344@ocean.vvo.ru> What is the difference between with-active-layers and with-active-layers* in ContextL? -- Registered Linux User #124759 From pc at p-cos.net Fri Feb 16 09:23:04 2007 From: pc at p-cos.net (Pascal Costanza) Date: Fri, 16 Feb 2007 10:23:04 +0100 Subject: [closer-devel] remove a layered method In-Reply-To: <20070216022220.GU344@ocean.vvo.ru> References: <20070216022220.GU344@ocean.vvo.ru> Message-ID: <78BCEA0B-96DE-4C34-99AF-49EEFD432247@p-cos.net> On 16 Feb 2007, at 03:22, Igor Plekhov wrote: > How can I remove a layered method (previously defined with > define-layered-method)? I am terribly sorry, but there is currently no easy way to achieve this. I will fix this as part of completing the ContextL API soon. Until then, here is a workaround that you can use: Assume, you have defined a layered function foo like this: (define-layered-function foo (x y z)) Such a definition actually creates two functions: The function foo that you can call, and an internal generic function that takes the method definitions. I separate layered functions into to functions internally so that I can easily add the implicit parameter that represents the current layer combination. The name of the internally created generic function can be accessed via contextl::get-layered-function-definer-name, so if you want to access the generic function, you can call: (fdefinition (contextl::get-layered-function-definer-name 'foo)) You can then call generic-function-methods on that generic function. You can also call find-method, remove-method and add-method. However, note that the methods take the additional layer parameter, so you have to watch out to use the correct specializers. As I said, I hope I can provide a better interface soon. Let me know if the above works for you. Cheers, Pascal -- Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net Vrije Universiteit Brussel, Programming Technology Lab Pleinlaan 2, B-1050 Brussel, Belgium From pc at p-cos.net Fri Feb 16 09:38:49 2007 From: pc at p-cos.net (Pascal Costanza) Date: Fri, 16 Feb 2007 10:38:49 +0100 Subject: [closer-devel] with-active-layers In-Reply-To: <20070216043717.GV344@ocean.vvo.ru> References: <20070216043717.GV344@ocean.vvo.ru> Message-ID: On 16 Feb 2007, at 05:37, Igor Plekhov wrote: > What is the difference between with-active-layers and > with-active-layers* in ContextL? You can use with-active-layers in two ways: (1) Just with layer names: (with-active-layers (l1 l2 l3) ... some code ...) (2) With additional initargs: (with-active-layers ((l1 :foo 42)) ... some code ...) The second use assumes that the layer l1 has been defined with a special slot with :foo as an initarg, for example like this: (deflayer l1 () ((foo :initarg :foo :special t :reader foo))) The layer activation (2) additionally rebinds the layer-specific slot 'foo with dynamic scope. The two variations with-active-layers and with-active-layers* only make a difference when such dynamically scoped rebindings of layer- specific special slots are involved. The difference is as follows. Assume you additionally have the following layer definition: (deflayer l2 () ((bar :initarg :bar :special t :reader foo))) Now let's investigate the following two forms: (a) (with-active-layers ((l1 :foo (bar (find-layer 'l2))) (l2 :bar (foo (find-layer 'l1))) ...) (b) (with-active-layers* ((l1 :foo (bar (find-layer 'l2))) (l2 :bar (foo (find-layer 'l1))) ...) The difference between (a) and (b) is that in (a), the calls (bar (find-layer 'l2)) and (foo (find-layer 'l1)) will both see the values of the outer bindings for the slots 'bar and 'foo, while in (b), the call (foo (find-layer 'l1)) will already see the new binding for the slot 'foo, i.e., the value as returned by (bar (find-layer 'l2)) in the line before. This is similar to the difference between let and let*, where all variable references in let will see outer bindings, whereas variable references in let* will successively see the previously established bindings of the same let* form. No, I don't have a practical use case for with-active-layers*. ;) I just wanted to be complete here... I hope this helps, Pascal -- Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net Vrije Universiteit Brussel, Programming Technology Lab Pleinlaan 2, B-1050 Brussel, Belgium From penguin at ocean.vvo.ru Sat Feb 17 12:25:30 2007 From: penguin at ocean.vvo.ru (Igor Plekhov) Date: Sat, 17 Feb 2007 22:25:30 +1000 Subject: [closer-devel] remove a layered method In-Reply-To: <78BCEA0B-96DE-4C34-99AF-49EEFD432247@p-cos.net> References: <20070216022220.GU344@ocean.vvo.ru> <78BCEA0B-96DE-4C34-99AF-49EEFD432247@p-cos.net> Message-ID: <20070217122530.GX344@ocean.vvo.ru> On Fri, 16 Feb, 2007 at 10:23:04 +0100, Pascal Costanza wrote: > > >How can I remove a layered method (previously defined with > >define-layered-method)? > > (define-layered-function foo (x y z)) > (fdefinition (contextl::get-layered-function-definer-name 'foo)) > Let me know if the above works for you. Yes, it does. #'contextl::get-layered-function-definer-name gives me some symbol, using which I can easily get a list of function's methods in Slime's inspector. -- Registered Linux User #124759