[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Adding several methamethods could be helpful
- From: HyperHacker <hyperhacker@...>
- Date: Sat, 26 Mar 2011 17:26:41 -0600
On Sat, Mar 26, 2011 at 15:54, Rebel Neurofog <rebelneurofog@gmail.com> wrote:
> Hi!
>
> My suggestion is about implementing '*=', '/=', '-=', '+=', '%=' and
> '^=' operations for user data and tables only.
> I would name that "__mulself", "__divself", "__subself", "__addself",
> "__modself" and "__powself".
>
> This would be helpful in code like that:
>
> function translate_rotate (source_matrix, translation, rotation)
> -- source_matrix is 'mat4' userdata
> -- translation is 'vec3' userdata
> -- rotation is 'quaternion' userdata
> local destination_matrix = source_matrix.translate translation()
> destination_matrix *= rotation
> return destination_matrix
> end
>
> Since we are dealing with mutable data, this could be very helpful for
> efficiency still keeping module API sweet.
>
> On the other hand, I'm strictly against using these things on
> immutable data types (like 'sum += 3.5' for 'sum = sum + 3.5'):
> Lua must not turn into messy thing like Python.
>
> What do you think?
>
>
I don't see the sense in supporting them for some types and not others.
--
Sent from my toaster.