emacs-devel
[Top][All Lists]
Advanced

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

Re: Watchpoints for emacs lisp.


From: Ken Raeburn
Subject: Re: Watchpoints for emacs lisp.
Date: Tue, 11 May 2010 21:53:17 -0400

On May 11, 2010, at 09:54, A. Soare wrote:
>>> I insert to the struct Lisp_Symbol a field :watched: .
>> 
>> So, no support for watching for an element of an array or pair to be 
>> changed, or part of a string?
> 
> Hm... I thought only to symbols, true. Not to arrays, not to numbers.
> 
> Can you use the change of an array if a symbol does not point to it? Probably 
> yes. There exist lambda function (functions without name), but probably one 
> can debug also the change of an array without name.

The 'aset' function can change an element of a vector or string (or certain 
other objects), in place.  So any existing references to the containing 
vector/string/whatever will now see the new element.  Similarly, setcar and 
setcdr can change the values contained within a cell that may be referred to 
elsewhere, and the change will be visible.  This isn't the case with numbers, 
as numbers can't act as containers or references for other values.

>> What about changes to the property list, or function value, of a symbol?
>> 
> 
> Can you figure an algorithm for checking very fast (O (0)) whether a symbol 
> has a given property ?

I don't think that matters.  You could have the flag on the symbol indicate 
that the handler should be called if *any* of the slots are changed (function, 
value, plist, aliasing, becoming buffer-local, etc).  The property list may be 
changed by changing the 'plist' field in the C structure, which would be 
noticed by the above mechanism, or it can be changed by altering elements of 
the list stored in the 'plist' field.  If you make it possible to watch for 
changes to a cons cell, though, that could be applied to the (original) 
property list itself.  (Managing that and figuring out when to stop watching 
those cells could be tricky, but the fundamentals would be there.)

However, I don't think there's any spare room in a cons cell allocation at the 
moment.  Doing this efficiently, and ideally without getting too intimate with 
the garbage collection system, could be difficult... perhaps watching symbols 
would suffice for a first cut, and cons cells could be worked on later if 
desired.  (But I'd still suggest you have the watchpoint trigger for changes to 
*any* field of a symbol, not just the 'value' field.)

Ken


reply via email to

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