I did a few more tests.
x = {}
x["y"] = 3
print(x.y) -- 3
x["f1"] = 4
print(x.f1) -- 4
x["3"] = 4
--print(x.3) -- invalid
print(x[3]) -- nil
print(x["3"]) -- 4
Quite expected. Then more tests:
box = {}
key = "xxx"
box.yyy = {numcol=3}
box[key] = {numcol=2}
function box.yyy:click_cb(L,C)
end
print(box.yyy.numcol) -- 3
print(box.xxx.numcol) -- 2
print(box["xxx"]) -- table: 0000005B439B0F60
print(box["xxx"].numcol) -- 2
print(box[key]) -- table: 0000005B439B0F60
print(box[key].numcol) -- 2
function box.xxx.click_cb() -- OK
--function box[key].click_cb() -- Error
end
And finally doing this:
box[key].click_cb = function () -- OK
end
Best,
Scuri
On Thu, Jul 9, 2015 at 10:46 PM, Antonio Scuri <sc...@tecgraf.puc-rio.br>
wrote:
> Interesting.
>
> This also does not work:
>
> function box[key].click_cb(self, L,C)
>
> And it is not related to IupLua. I tested with:
>
> box[key]= {numcol=2, numcol_visible=2, numlin=0}
>
> An the result is the same.
>
> It seems it is not a valid Lua declaration. You should post at the Lua
> list to get a better answer... :)
>
> On the other hand, this is valid:
>
> box[key].click_cb = function(self, L,C)
>
> According to the Lua documentation:
>
> The statement
>
> function t.a.b.c.f () *body* end
>
> translates to
>
> t.a.b.c.f = function () *body* end
>
>
> So for me it was the same as above. But then, I guess it is not. It does
> not work in any Lua 5.x.
>
> Interesting again.
>
> Anyway, Milind already answer it. Thanks!
>
> Best,
> Scuri
>
>
> On Thu, Jul 9, 2015 at 9:45 PM, John Huttley <j...@mib-infotech.co.nz>
> wrote:
>
>> Hi,
>> I've been doing a bit of programming with IUP LUA under windows.
>>
>> And have discovered this oddness.
>> ===========
>> require( "iuplua" )
>> require( "iupluacontrols" )
>>
>> box = {}
>> key = "999"
>>
>> box[key]= iup.matrix {numcol=2, numcol_visible=2, numlin=0}
>>
>>
>> local box_key = box[key] -- This works
>> function box_key:click_cb(L,C)
>> end
>>
>>
>> -- The function def below doesn't like the [key], doesn't compile
>> function box[key]:click_cb(L,C)
>> end
>>
>>
>> ========
>>
>> I'm at a loss to understand why the latter function doesn't compile.
>>
>> Any advice greatfully received.
>>
>> --John
>>
>>
>> ------------------------------------------------------------------------------
>> Don't Limit Your Business. Reach for the Cloud.
>> GigeNET's Cloud Solutions provide you with the tools and support that
>> you need to offload your IT needs and focus on growing your business.
>> Configured For All Businesses. Start Your Cloud Today.
>> https://www.gigenetcloud.com/
>> _______________________________________________
>> Iup-users mailing list
>> Iup-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/iup-users
>>
>>
>
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users