Closed porky11 closed 7 years ago
I'm not really sure, if there isn't a better solution
Another option may be defining the functions of the enum in the default namespace. I think this is the better solution. Maybe when existing functions are overloaded on some new type, they should be defined in the original namespace instead (normally the default namespace), since you would like the original function names with the new types, but are not able to use everything in the namespace becuase of name conflicts.
I think, the other solution would be preferable
I rewrote enum.dt It works similar to the original enum version again, where you had to write
(enum value)
instead of justvalue
when it was defined like this(def enum (enum intern uintt ((value 0))))
This is useful, because some enums may be big and contain many already used names (when they are similar to the c-names of objects, but without prefix for example) or when multiple enums contaion the same objects (see #149). If the enum is defined in another namespace, the operations are also defined in this namespace and you have to writeenum-namespace.+
to sum 2 enums for example.Now
def-enum
defines the new type in the current namespace, and creates a namespace, where the variables of the enum are defined. it will also create a macro similar to the original version of the macro. so there are 3 ways to use the enum variables:(enum value)
(expands to(using-namespace enum value)
) (also works with a expression using value)enum.value
(using-namespace enum …value…)
(this may be most useful when enum values should be used as global variables (because they don't conflict with other symbols normally)) Currently this does not work correctly since the subnamespaces of the namespace, where the enum is defined is not inherited and only referenced by name. this could be solved with #154