help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two questions about generalized variables


From: Eric Abrahamsen
Subject: Re: Two questions about generalized variables
Date: Tue, 23 Feb 2016 11:19:02 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

Michael Heerdegen <michael_heerdegen@web.de> writes:

> 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.

Right, that was my question, I guess -- I would do this with
`gv-define-setter', right? Its docstring is a bit impenetrable, but if
that's the right place to start I can figure it out.

>> >> 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.

Ah, of course! It's pushing to a place, not a value, that's the whole
point. Thank you for turning the light on there.

Last question: How do I actually see the gv-expander of `alist-get'?
Where is that?

Thanks again,
Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]