[parenscript-devel] How to generate element[i].childNodes[0].nodeValue
Wout Perquin
wout.perquin at skynet.be
Tue Dec 1 21:05:40 UTC 2009
Hi Vladimir,
GET-PROPERTY is certainly a better name then SLOT-VALUE, but why not
calling it PROPERTY, that is more generic and also 4 characters shorter.
It would make sense in constructs like SETF.
If I had the choice between :
(setf (get-property foo 1 2 'bar) value) ; and
(setf (property foo 1 2 'bar) value)
I would pick PROPERTY because it is shorter and it says exactly what it
is about ... a property of a JavaScript object.
But ... if you want to go a step further, because what SLOT-VALUE is
actually addressing/pointing/referring to, is either a property, a
function, or an object, you can consider to call it MEMBER, which is
even a shorter name and even more generic.
If you would ask me, I would go for MEMBER
(setf (member foo 1 2 'bar) value ; how shorter and abstracter could one
go :)
Regards, Wout
On Mon, 2009-11-30 at 22:56 -0500, Vladimir Sedach wrote:
> This is actually a cool example. I never thought about using
> SLOT-VALUE that way. I'm rewriting the reference manual right now
> (should be done in a couple of days), I'll make sure to mention this.
>
> The way the @ macro works is actually just by quoting all symbols it
> finds and passing its arguments to SLOT-VALUE.
>
> One thing is that I renamed SLOT-VALUE to GET-PROPERTY in the
> repository version, since what the form did really didn't have
> anything in common with Common Lisp's SLOT-VALUE, as someone pointed
> out.
>
> Thanks,
> Vladimir
>
> 2009/11/25 Wout Perquin <wout.perquin at 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 at 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 at common-lisp.net
> > http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
> >
>
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
More information about the parenscript-devel
mailing list