[parenscript-devel] How to generate element[i].childNodes[0].nodeValue
Red Daly
reddaly at gmail.com
Tue Dec 1 19:10:54 UTC 2009
On Mon, Nov 30, 2009 at 7:56 PM, Vladimir Sedach <vsedach at gmail.com> 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.
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). We
should also note that this will break a lot of code, which generated
some criticism with the last Parenscript release.
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).
Best,
Red
>
> 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