lua-users home
lua-l archive

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


On Mon, Jan 17, 2005 at 10:47:39AM +1000, David Burgess wrote:
> So why does my example print two copies of "hello" ?
> Also why does
> >  load(function() return 1  end)
> generate an infinite loop?

The reader function is supposed to return bytes to the lexer and nil to
signal end of file. Just like the one in lua_load.

Here is a silly example:

 local a={ "ret", "urn 1+", "2*4" }
 local n=0

 local f,e=load(function ()
         n=n+1
         return a[n]
 end)

 print(f())

--lhf