lua-users home
lua-l archive

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


On 24 June 2011 21:53, Gavin Wraith <gavin@wra1th.plus.com> wrote:
> In message <BANLkTi=ndaPq1pPopn=Jjh7KwVmbo2PEUA@mail.gmail.com> you wrote:
>
>> On 24 June 2011 21:26, Patrick Donnelly <batrick@batbytes.com> wrote:
>> > On Fri, Jun 24, 2011 at 3:57 PM, Kev Lugli <kevlugli@gmail.com> wrote:
>> >> Hi, I'm trying to do something like this, but I've got no success yet.
>> >>
>>
>> and you don't need _G:
>>
>> a = 'func'
>> var = {}
>>
>> var[a] = function (a)
>>  print(a)
>> end
>
> This is simply
>
>  var = { func = print }
>
> if you overlook the variadic nature of print. I am asking myself if
> somewhere along the way someone had overlooked the fact that
> the variable 'a' is a constant (i.e. bound to 'func') on the
> lefthand side of the assignment but a dummy variable (i.e. bound by
> 'function') on the righthand side. Or have I misunderstood the point
> of the exercise?
>

Maybe, but perhaps I did - I just assumed the function would do
something more useful than (unsuccessfully) wrap print() :)

Regards,
Matthew