Re: [pro] When to use SLOT-VALUE...

2010-12-02 Thread David Owen
On Thu, 2 Dec 2010, Ben Hyde wrote: > On Dec 2, 2010, at 4:38 PM, David Owen wrote: >> Perhaps you are looking for WITH-ACCESSORS? > > Indeed, I'm delighted to discover there is something in the language > I've not used. thanks! > > Further I didn't know that setq turns into setf with the help o

Re: [pro] When to use SLOT-VALUE...

2010-12-02 Thread Ben Hyde
On Dec 2, 2010, at 4:38 PM, David Owen wrote: > On Thu, 2 Dec 2010, Ben Hyde wrote: >> Anyhow. Recall that with-slots expands to slot-value. That leads >> me to wonder. Given that with-slots and slot-value are couple, why >> haven't I observed analogous couple (with-fields and field-value >> say

Re: [pro] When to use SLOT-VALUE...

2010-12-02 Thread David Owen
On Thu, 2 Dec 2010, Ben Hyde wrote: > Anyhow. Recall that with-slots expands to slot-value. That leads > me to wonder. Given that with-slots and slot-value are couple, why > haven't I observed analogous couple (with-fields and field-value > say) for accessors. Perhaps you are looking for WITH-A

Re: [pro] When to use SLOT-VALUE...

2010-12-02 Thread Scott McKay
The system that Dan and I are working on does, in fact, have a 'with-accessors' macro that does just what you think. On Dec 2, 2010, at 12:37 PM, Ben Hyde wrote: > On Dec 1, 2010, at 9:51 AM, Daniel Weinreb wrote: >> The methods called by the callers (1) expect to find the object in a >> consiste

Re: [pro] When to use SLOT-VALUE...

2010-12-02 Thread Ben Hyde
On Dec 1, 2010, at 9:51 AM, Daniel Weinreb wrote: > The methods called by the callers (1) expect to find the object in a > consistent state, and (2) must leave the object in a consistent state > when they terminate, whether they terminate normally (return) or > abruptly (signal, return, throw, etc.

Re: [pro] When to use SLOT-VALUE...

2010-12-01 Thread Daniel Weinreb
You considered the idea that when you write a library (internal module, whatever) that defines a new type of Lisp object, it should not necessarily be apparent to the caller whether the implementation of objects of that type happen to use CLOS. Hans: Of course, one may want to argue that DEFCL

Re: [pro] When to use SLOT-VALUE...

2010-12-01 Thread Daniel Weinreb
Sorry for the delay; here are my comments. Meta-point: I prefer to work out these issues by first disregarding speed issues, and figuring out what the best semantics is. Then, later, if there is real need for speedup, we can do that, but keep in place the original intention of the code, for the

Re: [pro] When to use SLOT-VALUE...

2010-11-22 Thread Hans Hübner
By private email, James Anderson pointed out that accessors are traceable, whereas SLOT-VALUE is not. To me, that is the most convincing argument for always using accessors, even in class-internal initialization code. Thanks for all your input! -Hans On Tue, Nov 16, 2010 at 11:05 AM, Hans Hübne

Re: [pro] When to use SLOT-VALUE...

2010-11-16 Thread Nikodemus Siivola
On 17 November 2010 00:07, Scott L. Burson wrote: > Presumably the automatically generated methods for the accessor use the > optimization internally, but the compiler can't inline those methods -- it Basically yes. (Also, in addition to Andreas' caveat about implementation differences, note tha

Re: [pro] When to use SLOT-VALUE...

2010-11-16 Thread Andreas Fuchs
On Tue, Nov 16, 2010 at 13:15, Nikodemus Siivola wrote: > Of course, readability and maintainability trump efficiency any time, > as long as the code if efficient enough for its intended purpose. I'm not sure that it's entirely right to say slot-value will definitely be faster. It may be faster i

Re: [pro] When to use SLOT-VALUE...

2010-11-16 Thread Scott L. Burson
On Tue, Nov 16, 2010 at 1:15 PM, Nikodemus Siivola < nikode...@random-state.net> wrote: > I *think* permutation vectors can be extended to accessors > as well, but I don't know how commonly that is implemented (eg. SBCL > at least currently doesn't) Presumably the automatically generated methods

Re: [pro] When to use SLOT-VALUE...

2010-11-16 Thread Nikodemus Siivola
One angle that hasn't been mentioned yet is efficiency. There's a fairly well known optimization (permutation vectors) that allows (defmethod foo ((x bar)) ... (slot-value x 'quux) ...) to be very efficient as long as X isn't assigned to (and as long as there is not SLOT-VALUE-USING-CL

Re: [pro] When to use SLOT-VALUE...

2010-11-16 Thread Scott L. Burson
On Tue, Nov 16, 2010 at 2:22 AM, Pascal Costanza wrote: > > Note that it is always possible to have several accessors with different > names. So you could define something like this: > > (defclass foo () > ((some-slot :reader official-slot-reader :accessor > %internal-slot-accessor) ...)) > > I

Re: [pro] When to use SLOT-VALUE...

2010-11-16 Thread Pascal Costanza
On 16 Nov 2010, at 11:05, Hans Hübner wrote: > Hi, > > The company I work for has a Common Lisp style guide that generally disallows > using SLOT-VALUE. Instead, accessor should be used so that: BEFORE and > :AFTER methods are always invoked when accessing a slot. Generally, I think > this

[pro] When to use SLOT-VALUE...

2010-11-16 Thread Hans Hübner
Hi, The company I work for has a Common Lisp style guide that generally disallows using SLOT-VALUE. Instead, accessor should be used so that: BEFORE and :AFTER methods are always invoked when accessing a slot. Generally, I think this is a good idea when looking at classes and instances from the o