emacs-devel
[Top][All Lists]
Advanced

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

Re: testcover: setf-method and treatment of `defcustom'


From: Stefan Merten
Subject: Re: testcover: setf-method and treatment of `defcustom'
Date: Wed, 12 Sep 2012 22:38:28 +0200

Hi Stefan and Jonathan!

Yesterday Stefan Monnier wrote:
>>      No setf-method known for testcover-after
> 
> Does one of the 2 patches work?

I'd need to compile and install an Emacs 24 version for this to try.
Frankly so far I didn't do so. I'll give it a try.

>> I looked into this and found `defsetf' in `cl-macs'. `testcover-after'
>> is a function which has only some side effect.  I think
>>   (defsetf testcover-after (idx val) (store)
>>     (list 'progn
>>        (list 'testcover-after idx val)
>>        (list 'setf val store)))
>> does the right thing.  At least the error messages described above
>> vanish for me.
> 
> I'm not sure what we should do, but the above doesn't sound quite right.

This may well be. I do not fully understand what I'm doing there ;-) .

>> AFAICS the only thing which can go wrong with this setf-method seems
>> to be the double evaluation of `val'
> 
> In (setf (testcover-after IDX (aref A I)) V), your defsetf will be
> called with a `val' that's a temporary variable bound to the value of
> (aref A I), so double evaluation is not a problem.

Ok.

> But your `(setf ,val
> ,store) will end up changing some temporary variable rather than
> changing the I'th slot of the A vector.

Oops. My intention with ",val" was to expand the original form before
binding it to val into this place so `setf' treats the original form.
May be that's not possible with `defsetf'.

> My 1st patch has the downside that it doesn't call testcover-after at all.
> The reason is that I don't know what VAL to set in IDX when we do
> things like (push VAL (testcover-after IDX PLACE)): should it be the
> value read before pushing VAL onto it, or the value set afterwards?

My cent: Before pushing VAL. AFAICS `testcover-after' needs to see
PLACE unmodified.


                                                Grüße

                                                Stefan

Attachment: pgp8oJ1mkBgu_.pgp
Description: PGP signature


reply via email to

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