Re: Local/temporary methods in CLOS

Liste des GroupesRevenir à cl lisp 
Sujet : Re: Local/temporary methods in CLOS
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.lisp
Date : 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/contextl

Also 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/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
11 Mar 25 * Local/temporary methods in CLOS5Stefan Monnier
11 Mar 25 `* Re: Local/temporary methods in CLOS4Kaz Kylheku
11 Mar 25  `* Re: Local/temporary methods in CLOS3Stefan Monnier
12 Mar 25   `* Re: Local/temporary methods in CLOS2Kaz Kylheku
12 Mar 25    `- Re: Local/temporary methods in CLOS1Stefan Monnier

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal