Deutsch   English   Français   Italiano  
<20250311140945.99@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.lang.lisp
Subject: Re: Local/temporary methods in CLOS
Date: Tue, 11 Mar 2025 21:41:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <20250311140945.99@kylheku.com>
References: <jwvtt7z70hp.fsf-monnier+comp.lang.lisp@gnu.org>
Injection-Date: Tue, 11 Mar 2025 22:41:03 +0100 (CET)
Injection-Info: dont-email.me; posting-host="d4918c5f3d619c897c5da0da622d2ee8";
	logging-data="2309878"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/WN8/UfiO8CmylQDFp7LuGGvE0Kj9ZDbg="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:Sf7WgVp7vY0h5pLoMqS0UBCdCu8=
Bytes: 2119

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