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

Re: enum and named sets


It is not the same thing, enums are constants used at compile time, no overhead at all.
so having to reference a collection, is just unneeded overhead.
enum constants are very fast.

So my suggestion is to have the compiler not change how it uses enum now, but create a static read only integer array by the set name. It does not interfere with the current performance of the interpreter but does allow access to the set create by the enumeration.

so
enum myset red=5,blue=6,green=89
the enums are used like the constants they are very fast for the interpreter
but the compiler creates internally
integer array read only  myset = [5,6,89] it keeps the performance, but allows access to the set of constant value in one place.

my thoughts anyway.

On 12/7/25 23:54, Fabien Bodard wrote:
Private ThisSetName As Collection = ["this_set_name  none":0,"fast":1, "slow":2,"red":3,"green":4]

dim setcounter[] as new integer[ThisSetName!5]
inc setcounter[ThisSetName!none]
inc setcounter[ThisSetName!green]

 for each xx as variant in ThisSetName
  print setcounter[xx]
 next


and in your case

for i = 0 to 4
print setcounter[i]
next

does the same

... no ?

Fabien Bodard


--
~~~~ Brian

Attachment: OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


References:
enum and named setsBrian G <brian@xxxxxxxxxxxxxxxx>
Re: enum and named setsBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: enum and named setsFabien Bodard <gambas.fr@xxxxxxxxx>