libminizinc icon indicating copy to clipboard operation
libminizinc copied to clipboard

Feature request: Defining enums in let-blocks

Open zayenz opened this issue 2 years ago • 1 comments

I would like the following code to be valid

constraint 
    let {
        enum Foo = {Bar};
    } in true;

Currently (version 2.6.3) this just generates MiniZinc: syntax error: syntax error, unexpected enum.

While the above code is not interesting, using enums in let-blocks can be useful when constructing data-structures inside constraints, predicates, and functions. For example, when creating a finite automata for regular, using an enum enum States = State(1..nstates) could make the code clearer.

zayenz avatar Jun 13 '22 14:06 zayenz

It does sound like there are interesting use cases for this. At the moment this might be a bit tricky to implement since both the identifiers of enumerated types and their elements populate the global namespace.

Dekker1 avatar Jun 14 '22 00:06 Dekker1