I disagree with that characterization of SLOT-VALUE, since it is very similar to SLOT-VALUE in lisp but the slots have different semantics (MOP semantics in Lisp and hash-map semantics in Javascript).
The bigger problem is that now PS SLOT-VALUE has a completely different argument signature from the CL one, and people will use that. So there's no way to get PS code that uses it to work in CL, and it also conflicts if you want to implement CLOS in PS (I imagine this might be a problem for PSOS).
We should also note that this will break a lot of code, which generated some criticism with the last Parenscript release.
Yes, I put SLOT-VALUE in the deprecated interface list, which will issue a warning. This isn't an incompatible change, good thing for everybody.
Not that it's a big deal to rename things, and PROPERTY-VALUE is a good alternative. I suppose because of the simpler semantics of the object system in Javascript that even calling it PROPERTY, as suggested, is not ambiguous. (If it were Lisp, SLOT could designate the slot metaobject as opposed to the slot value for a given instance).
Since the JS terminology calls object slots properties, it definitely makes sense to call the accessor something to do with "property." The three choices so var are GET-PROPERTY, PROPERTY, and PROPERTY-VALUE. I like GET-PROPERTY because it has a similar convention to GETHASH and GETF. On the other hand, if it were really similar, it might be called GETPROP. There's something ambiguous about PROPERTY, it's hard to tell if it's an accessor at first sight. PROPERTY-VALUE is like SLOT-VALUE, but it's the longest to type.
GETPROP is concise and Lispy. Thoughts?
Vladimir
Best, Red
Thanks, Vladimir
2009/11/25 Wout Perquin wout.perquin@skynet.be:
Hi Red,
It works on my version too (*) It is a clean solution that I like a lot. I did some tests and the slot-value operator is quite versatile. In fact it makes aref redundant because (slot-value foo 1 2 3) renders the same as (aref foo 1 2 3).
It also allows constructs like : (slot-value foo 1 "two" three 'bar 1 2) => "foo[1]['two'][three].bar[1][2];" //not necessary meaningful but possible :)
I believe the versatility of slot-value should make it to the reference.
Many thanks. Best wishes, Wout Perquin
(*) not sure what version I have, but the changelog youngest entry is from Nov-4, 2007
On Wed, 2009-11-25 at 00:10 -0800, Red Daly wrote:
On Tue, Nov 24, 2009 at 12:43 PM, Wout Perquin wout.perquin@skynet.be wrote:
On Tue, 2009-11-24 at 19:42 +0000, Wout Perquin wrote:
Hi, I would like to generate : "var value = element[i].childNode[0].nodeValue" in one sentence.
On my local version, slot-value accepts multiple slots:
(slot-value element i 'child-node 0 'node-value) =>"element[i].childNode[0].nodeValue;"
Nested @s and the like tend to become confusing, so I prefer this solution. I don't know if it is part of the current Parenscript or not.
Best regards, Red Daly
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel