Re: enum type
- Posted by ghaberek (admin) 3 days ago
- 75 views
irv said...
From the docs:
enum type color RED=4, GREEN=7, BLACK=1, BLUE=3 , PINK=10 end type ? color(RED) --> 1 ? color(GREEN) --> 2 ? color(BLACK) --> 3 ? color(BLUE) --> 4 ? color(PINK) --> 5 constant color_names = {"rouge", "vert", "noir", "bleu", "rose"} puts(1, color_names[color(BLUE)]) --> bleu
In real life:
irv@irv-desktop:~/new_gtk$ eui enums.ex 1 1 1 1 1 rouge
Euphoria Interpreter v4.2.0 development 64-bit Linux, Using System Memory Revision Date: 2025-01-24 03:31:36, Id: 22b5124
Edit: it seems to work correctly on 4.1
$ eui -v Euphoria Interpreter v4.1.0 development 64-bit Linux, Using System Memory Revision Date: 2015-02-02 14:18:53, Id: 5861:57179171dbed $ eui enumtest.ex 1 2 3 4 5 bleu
And I can confirm it's not working on 4.2
$ ./build-linux-x64/eui -c build-linux-x64/eu.cfg -v Euphoria Interpreter v4.2.0 release 64-bit Linux, Using System Memory Revision Date: 2024-11-17, Id: 5f6c867 $ ./build-linux-x64/eui -c build-linux-x64/eu.cfg enumtest.ex 1 1 1 1 1 rouge
I started digging into this and I'm more confused now that before I started. The way enum type is implemented is strange, to say the least.
ChrisB said...
Incidentally, it looks like enum overrides the assignments for a list of variables - is this expected behaviour?
Not sure what you mean by this. Could you provide an example?
-Greg