lua-users home
lua-l archive

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


> > [...adding enums of different types...g++ warning...]
> > While you may of course cast one of the enum values to int before doing the $
>
> I would much prefer the cast.  The semantics are the same (or at least
> very close to) and IMO the cast makes it significantly clearer to the
> reader what's going on.

Fair point. The Lua authors are the judge here.

> However, I would also argue that using enums as "just funny ints",
> which semi-must be going on for adding enums from different
> enumerations to make any semantic sense at all, is a Very Bad Idea,
> even in C.  IMO manifest constants whose actual values are important
> should be #defines, not enum members.  (If there's a real need for
> value-important int-ish manifest constants with the scoping properties
> of enum constants rather than of #defines, I would say the right thing
> is to create a new kind of manifest constant, not to abuse enums.)

I'm not a fan of #define constants at all, not even in C. When writing C, I use enum in preference to #define wherever practical. So I am member of the "just funny ints" school. Why they are such a bad idea has escaped me so far.

Adding enums wouldn't be a problem in C at all, but since Lua sources can be compiled as C++ the noted problem arises. C++ is much better equipped for defining constants without resorting to enum or #define, but that doesn't help for the Lua sources.

> > I wouldn't call it a bug, but [...]
>
> I would (would call it a bug, that is), but currently at just the
> semantic level.
>
> But what you or I think of it doesn't matter nearly as much as what the
> Lua people think of it.

Indeed. I intended merely to make them aware of the issue. I trust they will do the right thing.


Cheers
Stefan