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

Re: enum and named sets


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 ?




Le dim. 7 déc. 2025 à 21:58, Benoît Minisini <
benoit.minisini@xxxxxxxxxxxxxxxx> a écrit :

> Le 06/12/2025 à 21:03, Brian G a écrit :
> > Would it be useful or possible to allow the naming of enum sets such
> > that they could be referenced by that name
> > collectively without having to generate a special class with just a
> > public enum. This could be very useful I think.
> >
> > Or maybe there is already a simple way to do this!
> >
> > Such that
> >
> > enum this_set_name  none,fast, slow,red,green
> >
> > this allowing things like
> >      dim setcounter[] as new integer[5]
> >      inc setcounter[none]
> >      inc setcounter[green]
> >
> > or
> >
> >      for each xx as variant in this_set_name
> >          print setcounter[xx]
> >      next
> >
>
> I think this request already exists in the bug tracker.
>
> I don't know if it is possible to implement it in a way that does not
> hurt the interpreter speed.
>
> At the moment, enumeration symbols are just like constants: the
> interpreter does not have the information that they are all members of
> an enumeration, and does not know the name of that enumeration.
>
> Moreover, the enumerations symbols are just Integer at runtime. The
> enumeration is not a type by itself at all.
>
> I must think about it more.
>
> Regards,
>
> --
> Benoît Minisini.
>
>
>

-- 
Fabien Bodard

Follow-Ups:
Re: enum and named setsLee <t.lee.davidson@xxxxxxxxx>
Re: enum and named setsBrian G <brian@xxxxxxxxxxxxxxxx>
References:
enum and named setsBrian G <brian@xxxxxxxxxxxxxxxx>
Re: enum and named setsBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>