Subject: Re: bug#21798: 25.0.50; [PATCH] Add support for retrieving paths to JSON elements

From: Dmitry Gutov <[email-masked]>
Date: Fri, 6 Nov 2015 19:15:47 +0200

On 11/06/2015 06:31 PM, Simen Heggestøyl wrote:

> I'm reluctant to use advises for it, not based on my own experience, but
> based on advice from the Elisp manual:
>
>> [...] advice should be reserved for the cases where you cannot modify
>> a function’s behavior in any other way. [...] In particular, Emacs’s
>> own source files should not put advice on functions in Emacs. (There
>> are currently a few exceptions to this convention, but we aim to
>> correct them.)
>
> Here we do have a chance to modify the functions' behavior.

I happen to think that an advice with a short lifetime is okay, but yes, 
these are the guidelines.

> How about a sort of compromise between our approaches: provide
> 'json-read-object' and 'json-read-array' with pre- and post-read
> callback functions, that are only called when they're set. That would
> make it possible to leverage the power of 'json-read-object' and
> 'json-read-array' by binding the callback functions, without mixing
> alien logic into them.

That sounds fine to me in terms of design, but it might add some 
performance overhead. So some testing is needed.

> That would also make it a lot cleaner when adding other extensions to
> them in the future, compared to my original suggestion.
>
> If that sounds good to you, I'll cook up a new patch!

Please go ahead.