[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Two questions about generalized variables
From: |
Michael Heerdegen |
Subject: |
Re: Two questions about generalized variables |
Date: |
Sun, 21 Feb 2016 19:08:08 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.91 (gnu/linux) |
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> I didn't mean symbol property lists! Just the plain old '(:key1 "value1"
> :key2 "value2") kind. They're useful for a few different things -- in
> this case, initializing class instances.
Oh, I see. Hmm, one could define a place expander quite similarly to
the one of `alist-get', I think, but it doesn't seem one to be
predefined, indeed.
> >> The second question is setting hashtable entries. Right now I have code
> >> like this:
> >>
> >> (setf (gethash uuid my-hashtable)
> >> (append (list (list 'thingone 'thingtwo))
> >> (gethash uuid my-hashtable)))
> >
> > Isn't that more or less `push'?
>
> I started off with `push', but the code in question doesn't know if the
> key exists or not, and you can't push to nil.
The gv setter is calculated using the (unevaluated) place expression, so
"pushing to nil" doesn't happen. See the gv-expander of `alist-get' for
example, which of course also works for nonexistent keys.
Regards,
Michael.