[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Hooks for I/O, memory, etc?
- From: Pyrogon Public <public@...>
- Date: Mon, 10 Jun 2002 11:54:31 -0700
> About memory management, all calls are concentrated in a
> single point, so it is quite easy to change. Is it really a
> good idea to go a step further and implement that through a
> "callback" function?
Many other open source libraries do, in fact, do this. Off the top of
my head libpng and Ogg Vorbis both do this.
The reason is simple: many users want to customize non-invasively. In
my case, I don't want to ever "edit" the Lua source base, because I
don't want to re-integrate my changes every single time I grab a new
snapshot. That becomes tedious and potentially error prone.
Instead, the "obvious" candidates for customization such as memory
allocation and file i/o, can be trivially abstracted and default
implementations provided, which prevents us (i.e. people that want to
use Lua and do basic customization) from having to deal with Lua's guts
every time it changes. Which is a lot =)
I would guess that more than 75% of modifications to Lua for casual Lua
users are simply to override its IO and memory management.
The two most common modifications I do for any open source libs I use
are to override memory management (so I can provide my own heaps) and
file i/o (typically so I can do in-memory file-like access, since I
often preload files such as ZIP files).
Brian