lua-users home
lua-l archive

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


Thanks to everyone for the responses.

On 21 Nov 2012, at 13:05, Wolfgang Pupp wrote:

> IMHO this is clearly preferable over the C-way, where you have
> function definitions (and declarations) in completely random order
> (generally speaking).

This is definitely the mindset I'm coming from - although I would say organised rather than random. In my case, I did have some circular references, but it was made much worse by not keeping the functions in a define-before-use order. I may try and move to this way of thinking, but for now forgetting local functions, and defining functions in a local table seems to work well.

On 21 Nov 2012, at 11:47, Dirk Laurie wrote:

>> My best thought is that a relocal command that creates local
>> variables only if they aren't local in the same scope level.
> 
>> Is this a good idea, or am I just looking at the problem the wrong way?
> 
> After 18 posts, it has transpired that at least half the posters 
> didn't even understand the 'relocal' notion. 

I'm sorry if it wasn't clear. The keyword as I intended it would not solve David Favro's problem, as in this example:

> local rv1;
> repeat
>    relocal rv1, rv2 = foo();
>    until rv2;
> -- use rv1 here…

rv1 is an upvalue from the point of view of the relocal statement, hence a new rv1 would be declared shadowing the correct rv1.

Thanks,
Kevin