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

Re: enum and named sets


I say more like a structure because the compiler can resolve access at compile time with fixed field offsets rather than a lookup at runtime.

~~~~~ Brian


From: user@xxxxxxxxxxxxxxxxxxxxxx <user@xxxxxxxxxxxxxxxxxxxxxx> on behalf of brian <brian@xxxxxxxxxxxxxxxx>
Sent: Tuesday, December 9, 2025 10:23:52 PM
To: Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>; user@xxxxxxxxxxxxxxxxxxxxxx <user@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: enum and named sets

I was not really looking for syntactic sugar, but a way of handling the values as a single set. There are many advantages.  My implementation suggestion was to maintain performance.
Passing the set to an other class or function would be useful but then have to be more of a read only set.  But where defined remains constants  .  For public set would be more like a structure with readonly constant values.


~~~~~ Brian


From: user@xxxxxxxxxxxxxxxxxxxxxx <user@xxxxxxxxxxxxxxxxxxxxxx> on behalf of Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Sent: Tuesday, December 9, 2025 8:15:00 AM
To: user@xxxxxxxxxxxxxxxxxxxxxx <user@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: enum and named sets

Le 09/12/2025 à 03:55, Jussi Lahtinen a écrit :
> There should NOT exist private enums or enums which cannot be exported.
> Someone is going to use them in some library/interface and then change
> later breaks everything using the library.
> I have suffered this in C a few times. I never use enums.
>
> Jussi
>
I rarely use enum in C, prefering #define.

But if an enum is really private, how can it be used outside of where it
is declared?

If I make enumerations a pseudo-type in Gambas, private enumerations
will only be able to be used inside the class it is declared, exactly
like private static constants. They will be invisible and unknown from
the outside.

--
Benoît Minisini.





References:
enum and named setsBrian G <brian@xxxxxxxxxxxxxxxx>
Re: enum and named setsJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
Re: enum and named setsBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: enum and named setsbrian <brian@xxxxxxxxxxxxxxxx>