[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Mutating existing persistent data
From: |
Lars Ingebrigtsen |
Subject: |
Re: Mutating existing persistent data |
Date: |
Tue, 07 Dec 2021 06:08:43 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Po Lu <luangruo@yahoo.com> writes:
> Does this really have to be a generalized variable?
>
> Why not use something like `set-persistent-value' and
> `get-persistent-value'?
I think we're moving away from get/set pairs. We could have gone even
more magical -- reader macros!
Anyway, this is now working, I think, but of course the most difficult
bit, naming, is left to last. So basically:
(define-sticky-variable foo 'bar)
This defines a sticky wicket foo, I mean object, and `bar' is the
default value if there isn't one already stored. We access it like
this:
(sticky-value foo)
=> zot
There was apparently a stored value, so we got that back instead of the
initial value.
(setf (sticky-value foo) 'gazonk)
(sticky-value foo)
=> gazonk
These sticky values can be either synchronised or not. If they're
synchronised, `(sticky-value foo)' will check whether the value has been
updated externally (i.e., from a different Emacs session) and return
that value. If not, it returns the local value.
(push 'gazonk (sticky-value list-foo))
if `list-foo' is synchronised, will possibly read in the value from the
db first, prepend `gazonk' to it, and then write it back out again. (So
the other Emacs will get that value next time it accesses (sticky-value
list-foo).
RPC!!! 😱
But we should call this something other than "sticky", because that's
kinda sticky.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Re: sqlite3, (continued)
- Re: sqlite3, Po Lu, 2021/12/06
- Re: sqlite3, Arthur Miller, 2021/12/06
- Re: sqlite3, Po Lu, 2021/12/06
- Re: sqlite3, Qiantan Hong, 2021/12/06
- Re: sqlite3, Qiantan Hong, 2021/12/06
- Re: sqlite3, John Yates, 2021/12/06
- Re: sqlite3, Qiantan Hong, 2021/12/06
- Mutating existing persistent data (was: sqlite3), Stefan Monnier, 2021/12/06
- Re: Mutating existing persistent data, Lars Ingebrigtsen, 2021/12/06
- Re: Mutating existing persistent data, Po Lu, 2021/12/06
- Re: Mutating existing persistent data,
Lars Ingebrigtsen <=
- Re: Mutating existing persistent data, Po Lu, 2021/12/07
- Re: Mutating existing persistent data, Lars Ingebrigtsen, 2021/12/07
- Re: Mutating existing persistent data, Po Lu, 2021/12/07
- Re: Mutating existing persistent data, Lars Ingebrigtsen, 2021/12/07
- Re: Mutating existing persistent data, Lars Ingebrigtsen, 2021/12/07
- Re: Mutating existing persistent data, Po Lu, 2021/12/07
- Re: Mutating existing persistent data, Lars Ingebrigtsen, 2021/12/07
- Re: Mutating existing persistent data, Po Lu, 2021/12/07
- Re: Mutating existing persistent data, Qiantan Hong, 2021/12/07
- Re: Mutating existing persistent data, tomas, 2021/12/07