lua-users home
lua-l archive

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


>From lua-l@tecgraf.puc-rio.br Tue Jul 20 15:38:03 1999
>From: erik@hougaard.com (Erik Hougaard)

>Roberto Ierusalimschy wrote:
>> 
>> You can make the code ~20% faster using local variables:
>> 
>>   function sieve(n)
>>     local x = {}
>
>From the "correctness" perspective x should be a global variable,
>otherwise your would not be able to read the sieve list afterward.

You can always return x. The variable is local, but not the table it contains.
(If you do not return it, it will be collected as garbage, though.)
--lhf