Sujet : Re: Local/temporary methods in CLOS
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.lispDate : 11. Mar 2025, 22:41:02
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250311140945.99@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-03-11, Stefan Monnier <
monnier@iro.umontreal.ca> wrote:
I need some way to define "local" methods, which can override
temporarily "global" methods and obey some kind of dynamic scoping rule.
I feel that your requirements may be somewhere in the locus of
Pastal Costanza's work, like ContextL.
https://github.com/pcostanza/contextlAlso see Costanza's paper "Dynamically Scoped Functions as the
Essence of AOP" [2003].
Assuming I'm not the first to feel such a need, what are usual
approaches to try and provide that kind of behavior?
Since in Common Lisp we don't have dynamically scoped functions, only
variables, the straightforward thing, without using anyone's framework,
would be to use special variables to hold certain functions of interest,
and funcall them. (That can be wrapped or macroed over.)
(defun overridable-fun (&rest args)
(apply *overridable-fun* args))
(let ((*overridable-fun* (lambda (...) ...)))
(overridable-fun 42))
We can think about macros to make this look nicer.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca