[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Error messages from C
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 2 Jan 2001 20:03:54 -0200 (EDT)
>I recently wanted to create an error message in C.
>Rather than mess about in C concatenating bits of strings, I decided
>to push the strings onto the stack, lua_concat() them, and then
>call lua_error(L, lua_tostring(L, -1)).
> (a) Safe?
> (b) The most efficient way?
Depends on what you call "efficient".
It's certainly the most efficient in terms of your time.
Plus it avoids the hassle of memory allocation and the limitation of fixed-size
String concatenation is one of the services that Lua provides, which is
independent of the fact that is a full language.
Other services like that are hash tables and expression evaluation.