[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: More operators?
- From: "Cary O'Brien" <cobrien@...>
- Date: Mon, 5 Feb 2001 09:36:13 -0500 (EST)
[Charset iso-8859-1 unsupported, filtering to ASCII...]
>
> ----- Original Message -----
> From: Staffan Hellstr_m
> To: Multiple recipients of list
> Sent: Sunday, February 04, 2001 4:56 PM
> Subject: More operators?
>
>
> Hello,
>
> I have a question: How can I implement "arithmetic-assignment
> operators"(not sure on the exact term) like += and /= ?
> For clarification, a+=b is the same as a=a+b. However I've some users which
> want to be able to do += directly.
>
I kind of miss % for modulus. Ie. 11 % 5 = 1. Does this conflict with the
upuvar symbol in the lexer?
-- cary
> This is not a bad idea. Python has just added (i think they are called) augmented operators eg. +=, -=, in v2.0 after prolonged argument.
>
> I believe x += 1 would be faster for Lua than x = x+1, this is one of the reasons for adding it in Python besides convenience. ie. none mutable value becomes mutable in this case.
>
> I've looked at the source, and the biggest obstacle I can see(I think) is
> how to determine whether to use setglobal, setlocal, or settable for the
> assignment.
>