lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



在 2011-6-28 凌晨4:04,"Joshua Jensen" <josh.jjensen@gmail.com>写道:
>
> ----- Original Message -----
> From: Ian Millington
> Date: 6/26/2011 5:04 PM
>>
>> A while back I posted a commercial job offer for someone to help add
>> in-place mutation operators to Lua (+=, -=, *=, /=, %= and ^=). My
>> domain is in a scripting language for games, and a good deal of the
>> lua scripts consist of changing variable values, such as:
>>
>> target.health -= 2
>> player.ammo.shells -= 1
>>
>> so this saves a *lot* of typing.
>
> This just made my day.
>
> It isn't just about typing.  It's also about performance.  When written like:
>
>        player.ammo.shells = player.ammo.shells - 1
>
> Lua must:
>
> * Look up player.
> * Look up ammo.
> * Look up shells.
> * Subtract 1.
> * Look up player.
> * Look up ammo.
> * Set via hash the shells key to be the result of the subtraction.
>
> When written as "player.ammo.shells -= 1", Lua must:
>
> * Look up player.
> * Look up ammo.
> * Look up shells.
> * Subtract 1.
> * Directly store the result.
>
> Hooray!  (I hope this is how the patch works, anyway...)
>
> I have just pushed this to the LuaPlus repository on GitHub, #ifdef'ed as LUA_MUTATION_OPERATORS.

hi:)

I have some interesting with LuaPlus, for it add reference count to Lua.

I want to know is there any plans to improve and fix bug with it ?

Thank you
>
> Josh
>