lua-users home
lua-l archive

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


It's official behavior, and I would assume likely to remain the same in future 
versions, but I don't think it's the official behavior you think it is, given 
your subject line.

No local functions are created in this code. Instead, the "table.test" 
function replaces itself with a new function during its execution. If you 
executed table.test(123) twice, for example, the second time it would merely 
print the "internal test function" line.

Ben

On Wednesday 22 January 2003 03:57 pm, Markus Huber wrote:
> Is this an official behaviour also for future lua versions?
>
>    function table.test(number)
>       print('top')
>       function table.test(number)
>          print('internal test function',number*2)
>       end
>       table.test(number)
>       print('bottom')
>    end
>
>    table.test(123)
>
>    --> top
>    --> internal test function  246
>    --> bottom
>
> I would like to use this as an feature.
>
>
>
> Markus