[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Hooks for I/O, memory, etc?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 11 Jun 2002 09:12:41 -0300
> or make two versions of lua_open: one with no extra parameters, and one
> which lets you specify all the hooks.
What about varargs, with name-value pairs?
lua_open("realloc", &my_realloc, NULL)
> you could pass a pointer to a struct that holds the callback pointers to
> lua_open (defaulting to NULL).
About the plural "pointers": I understand this idea for memory
allocation, but not for I/O. The core does no I/O. In the libraries,
outside the I/O library, few functions do I/O or file operation
("print", "debug.debug", and load_file). It seems to me that it is
easier to redefine those functions (in your application, without
touching Lua code!) than to create a hook mechanism just to reuse those
few lines of code.
For the io library, it uses a lot of I/O operations; again, I don't
think it is a good idea to use hooks there...
-- Roberto