lua-users home
lua-l archive

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


On Fri, Jan 31, 2014 at 10:00 AM, Andrew Starks <andrew.starks@trms.com> wrote:
>
> On Fri, Jan 31, 2014 at 6:33 AM, Fabien <fleutot+lua@gmail.com> wrote:
>>
>>
>>> print("hello %s" % { "world" }).
>
>
> Hmmm.... dangit!
>
> I like this better. Except for that it uses a table, but this is sweet. The
> extra parens kind of kill the syntactic beauty of the __call method. If not
> for that, it'd win in my book.

I think it would be an improvement if the % operator also accepted
closures in this case:

"Hello %s" % function() return "world" end

It's generally lighter weight than tables and, if you have closure
caching with unchanging upvalues, it can be constant cost.

-- 
Patrick Donnelly