lua-users home
lua-l archive

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


>Does lua_load call this once ?  Or is there a loop like that:
>
>char *chunk;
>size_t size;
>while((chunk=read_chunk(ud,*size))!=NULL)
>{
> 
> compile_chunk_to_bytecode(...)
>}
>run_bytecode(...)

It's a loop, but not like this. It's the low-level loop in the lexer,
getting characters. Every time it runs out of characters it calls the
user function for more. This function returns NULL to signal EOF.

>If it  is the  loop, it  would be simple  to write  a line  based data
>format where just by a charcter in the first column.

Yes. That's why I've mentioned that what you wanted yo do was easy with
lua_load.

>I dived  into the  code of Lua  4, and  I believe that  it is  not too
>complicated to get this to work by modifying lzio.

That's the way we did it. See 5.0w0.

>If there would be no loop,  the user basically would be forced to read
>in the whole file  first, and we would need to keep  date once more in
>memory.

We certainly do not want to force the user to read it all at once. In fact,
the user may even hand 1 byte at a time, if necessary.
--lhf