[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Userdata management
- From: Oscar Lazzarino <osk@...>
- Date: Fri, 09 Nov 2001 09:24:23 +0100
Oscar Lazzarino wrote:
> I'm a new lua user, and I'm trying to understand how to manipulate
> userdata in lua.
OK, I tried and I tried and I tried, and finally I've managed to get
something working. I guess somethimes "no answer" is the best answer.
But now I have a different problem. It "strategic" problem and I'd like
to hear some suggestion from someone with more experience than me.
Here it is: imagine to have TWO different userdata types, with different
tags (T1 and T2). Imagine to have a single binary operator (let's say
"add"). Now, I can register a tagmethod for T1 and one for T2 (say
addT1() and addT2()), to add T1 with T1 and T2 with T2. This is OK.
Sadly, I'd also like to add T1 with T2, but lua calls addT1 if I do
T1+T2, and calls addT2 if I do T2+T1. It looks like there is no "direct"
way to register a function addT1T2.
Now, this situation is quite simple and could be managed quite
efficently, but the "real" situation is that I have more than two types,
and more than one binary operator.
How would you solve this?