lua-users home
lua-l archive

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


Hi Francisco

I admit I picked up a corner case.


1) In general, I dislike APIs returning unnecessary data.

If I call a function
     loadfile(const char * szFilename, ...)
it is obvious file errors are referred to szFilename !


2) Estimation of maximum size of error messages

If I use a library and functions can return error messages, I prefer they are constant string.
This way I know a priori the maximum size of the messages and there aren't nasty surprises regarding head and stack occupation.

I know I am finicky, but these concerns make it easier to write maintainable software, without side effects.
You really don't know which filenames will appear as input of your functions, when other users utilize them.

As people say in south Italy "ogni scarrafone è bello a mamma sua" "até o mais feio é lindo para sua mãe".
I mean: we write different code, and for everyone his code is the good one!

M


On Wed, 13 May 2020 at 22:00, Francisco Olarte <folarte@peoplecall.com> wrote:
Massimo:

First of all, I seem to have mixed your thread with another one (
Sorry Andrea ). It seems two Italian looking names are too much for me
to disambiguate, it makes me feel really old :( .

On Wed, May 13, 2020 at 6:59 PM Massimo Sala <massimo.sala.71@gmail.com> wrote:
> I agree, my use case is too specific.
> I solved pre-allocating a buffer for error strings before calling any lua function.
> Calculation the buffer size, I take care of the maximum length of filenames.
> When I get an error from lauxlib, I strncpy the error string to the preallocated buffer.

That's a way to do it. What surprises me is you have long filenames in
an embedded low memory systems, the ones I've used in this category,
when they had filesystems, had very simple ones.

Francisco Olarte.
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org