Deutsch English Français Italiano |
<jwvldtb55n7.fsf-monnier+comp.lang.lisp@gnu.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Stefan Monnier <monnier@iro.umontreal.ca> Newsgroups: comp.lang.lisp Subject: Re: Local/temporary methods in CLOS Date: Tue, 11 Mar 2025 23:00:07 -0400 Organization: A noiseless patient Spider Lines: 39 Message-ID: <jwvldtb55n7.fsf-monnier+comp.lang.lisp@gnu.org> References: <jwvtt7z70hp.fsf-monnier+comp.lang.lisp@gnu.org> <20250311140945.99@kylheku.com> <jwvo6y76xz0.fsf-monnier+comp.lang.lisp@gnu.org> <20250311165922.499@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 12 Mar 2025 04:00:07 +0100 (CET) Injection-Info: dont-email.me; posting-host="487b27025d8aef8cfa6c6843eb9243a2"; logging-data="2414838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Jli7DepS4tbEtEu+6yiVRoI9ho+/kT1U=" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:lveC50OG/kU1nIjMXMup/7lClTI= sha1:5rVoOXYRKHURtHLuA7aPZYyBKC8= Bytes: 3036 > I suspect Costanza's ContextL may speaks to these requirements. It does. > You are in some scope in which you would like to modify the behavior > of a generic function, so it has different methods. In "COP" > (context-oriented programming) that behavior would belong to a layer. > You dynamically activate and deactivate the layer (by name, I think). > The layer defines the methods (so physically they are not locally > enclosed in the scope(s) where you are activating the layer). That's a > feature, since you can activate a layer in multiple places. Here's an example: Say I implement a small DSL as a macro. That DSL may itself want to offer the ability to extend the language with macros. Each macro and special form in the DSL could map to a method (using an `eql` specializer on the head of the term, typically), so if you want your DSL to offer local macros (think `macrolet`), you need to temporarily add methods during the macro expansion of the subterms. For some DSLs it might make sense to define sets of macros which can be thought of as "namespaces", and then locally activate them, which maps neatly to ContextL's notion of layers and temporary activation of them. To take DSL examples from ELisp: - PEG has `define-peg-rule` (which could be implemented as defining a new method) but it also has `define-peg-ruleset` (which could map to defining a new layer) and then `with-peg-rules` (which can locally activate layers, and also define a new layer "on the spot"). - RX has `rx-define` as well as `rx-let` (which both defines a layer and activates it) but no way to define a layer separately from its activation. Yet, looking at RX users, the ability to define a set of RX constructs and activate them later would be welcome. - Pcase has `pcase-defmacro` but not "macrolet" equivalent. It would make a lot of sense to add some way to have local Pcase macros. Stefan