lua-users home
lua-l archive

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


In message <3AFFDD9E.230FA914@zkm.de>, Adolf Mathias writes:
> David Jones wrote:
> > 
> > In message <3AFC22C4.6406FD80@gmx.de>, Edgar Toernig writes:
> > > David Jones wrote:
> > > >
> > > > #define index 9
> > > > #include "lua.h"
> > > > /* ... */
> > >
> > > I would say that if you do this kind of mess it's your turn to
> > > clean up afterwards ;-)
> > 
> > Yes, well, _obviously_ index is a silly thing to #define.  Especially
> > before including Somebody Else's Header File.  But what am I allowed to
> > defined before including somebody else's header file?  stacksize, L, n,
> > s, len, u, tag, fn, str, filename, name?
> 
> I'd say #define'ing anything but symbols in all CAPITALS is dangerous

It's only dangerous because other people don't write their interfaces
completely cleanly.  For example: When using POSIX I can #define whatever
I like before including a header unless it is a symbol explicitly used
by the header, like mmap.  As a further example of the cleanliness of
the POSIX interface specs, even though index is defined in POSIX in
<strings.h> (historical equivalent for strchr), I can still #define it
before including <strings.h> as long as I haven't #defined
_POSIX_C_SOURCE (which enables POSIX functionality).

> and you should know exactly what you do, i.e. something like #define
> malloc(s_) my_favorite_malloc_debuger(s_). In my code, I also
> consistently use lowercase macro arguments with one underscore appended

Why do you append an underscore to macro parameter names?  There are no
unexpected pollution problems.  The body of the macro, which appears
immediately after the first space, is the only place where these names
have any meaning.

It seems to me like you don't isolate function parameter names, which are
prone to pollute, and you do isolate (a bit) macro parameter names,
which are not prone to pollute.

> and I always put them in parentheses, except where it absolutely makes
> no sense. From this point of view however, the ubiquitous function
> argument lua_State *L is dangerous.My minor point of criticism to the
authors of Lua is the not immediately obvious naming and capitalizing
> scheme in the Lua C source.

drj