lua-users home
lua-l archive

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


I agree. It would be even better if this IO redirection was dynamic.
e.g. If we assume that we have a set of function pointers like
lua_printf, lua_read ... , then we can easily change the input
mechanism, I had need for this a few years back in an app with
lua embedded that created and destroyed consoles.

David B.


On 3/2/06, Andy Stark <astark@blackpoolsixth.ac.uk> wrote:
> David Given writes:
> >
> >I have an embedded system with no stdio (not even FILE*),
> >
> >so had to hack all that stuff out of the Lua core. It was non-trivial.
>
> I have always thought it would be a major help to embedders if the Lua
> source NEVER used the I/O routines from the C standard library directly.
> They should all be wrapped inside functions defined in a single source
> file. The functions would be called something like "lua_printf", etc, and
> would simply pass their parameters onto the standard library routines. All
> other parts of the Lua source should then call lua_printf rather than just
> printf. Using this system, the crucial I/O routines would all be collected
> in one obvious place and would only have to be modified once by anyone
> having trouble with them.
>
> This would be a benefit in several cases:-
>
> - Places where no console output is available (eg, microwave oven or pure
> GUI environment like classic MacOS).
>
> - PalmOS and possibly others recommended that you use equivalent system
> calls instead of C standard library routines in order to save memory.
>
> - Plug-ins (eg, Photoshop) might need to report errors and messages by
> some pre-arranged mechanism rather than on the console.
>
> And there must be many other similar cases, all easily handled if the I/O
> routine calls are wrapped as described above. Lua's main unique "killer"
> feature is its superb embeddability - this feature should be developed as
> far as possible.
>
> Ideally, the Lua core (not including the file library, etc) should not use
> any I/O routines from the C standard lib, but should pass message strings
> upwards to be handled by the embedding program. This would probably be a
> major task, however, and might require the Lua team to write their own
> version of sprintf!
>
> Just a few observations from my experiences. No need to get angry if you
> disagree with me!
>
> &.
>
>
> #####################################################################################
> This e-mail message has been scanned for Viruses and Content and cleared
> by NetIQ MailMarshal.
> The Blackpool Sixth Form College.
> #####################################################################################
>