lua-users home
lua-l archive

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


On Mon, Feb 5, 2018 at 9:04 PM, Paige DePol <lual@serfnet.org> wrote:
> Nobody has an opinion on this style of typedef?
>
> The question may seem noob'ish, but really I am just curious if
> anyone else uses a typedef like this or if I am violating some
> sort of unwritten rule when coding in C.
>

It's not really an unwritten rule or anything but you have to consider
"what concrete value am I achieving with this change" and "what will
another programmer see when they look at this code".

const char * is an exceedingly common and standard way of passing
null-terminated string arguments, anybody who has programmed C before
will be able to recognise it immediately so all that you achieve by
hiding it behind a typedef is obfuscation because now a reader has to
investigate what a l_str is to understand the code.

Considering that Lua's code (and code in general) is read far more
often than it is written, saving a few characters is not a worthwhile
tradeoff.