[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "+="
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 11 Apr 2000 09:20:25 -0300 (EST)
>From: Gavin Wraith <gavin@wraith.u-net.com>
>Am I right in thinking that the Lua VM does two
>lookups in executing something like
>"a.b.c.d.e.f = a.b.c.d.e.f + 57" ?
Yes. Here is the code for a.x=a.x+57
main <@(stdin):0> (15 bytes at 0x80530d8)
0 04 STACK 4
1 00 ARGS 0
2 0F00 GETGLOBAL 0 ; "a"
4 0B01 PUSHCONSTANT 1 ; "x"
6 0F00 GETGLOBAL 0 ; "a"
8 1201 GETDOTTED 1 ; "x"
10 0739 PUSHNUMBER 57
12 25 ADDOP
13 1A SETTABLEPOP
14 00 ENDCODE
>This is presumably something which any language
>must address which allows complex L-value
>expressions. Any plans for this in a future
>release?
You have to keep in mind that getting and setting values in tables
may trigger tag methods and so an update operation like 'a.x += 57' really
is more complicated than it seems.
There are two reasons for wanting += : readability and efficiency.
I agree with readability but not with efficiency. Lua is already very fast
and even faster in the next version.
--lhf