[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Compatible coding: 'arg' in 5.1 vs 5.2
- From: Matthew Wild <mwild1@...>
- Date: Sat, 4 Jun 2011 00:25:01 +0100
On 3 June 2011 22:59, Leo Razoumov <slonik.az@gmail.com> wrote:
> On Fri, Jun 3, 2011 at 06:47, steve donovan <steve.j.donovan@gmail.com> wrote:
>> On Fri, Jun 3, 2011 at 12:25 PM, Dirk Laurie <dpl@sun.ac.za> wrote:
>>> Which is better?
>>
>> I would say: avoid the local 'arg' like the plague, it's a Lua 5.0 -ism ;)
>>
>
> I aways wondered how to get arg[0] (name of the current script) with {...}?
>
You can use the *global* 'arg' for command-line parameters. So arg[0]
is just fine.
The issue is that in 5.0, '...' did not exist inside functions, and a
magic 'arg' local appeared containing the function arguments instead.
This is deprecated in 5.1 in favour of '...' - it only works because
the Lua makefile enables deprecated features by default (to ease
transition to new versions). It's been known since the release of 5.1
that magic 'arg' would be gone entirely in 5.2.
Regards,
Matthew