[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: _G function inside table
- From: Patrick Donnelly <batrick@...>
- Date: Fri, 24 Jun 2011 22:20:05 -0400
On Fri, Jun 24, 2011 at 6:53 PM, Matthew Wild <mwild1@gmail.com> wrote:
> 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() :)
He was having trouble with the syntax/semantics. I was trying not to
distract from the problem by optimizing a frivolous example : /.
--
- Patrick Donnelly