MiniZinc / libminizinc

The MiniZinc compiler
http://www.minizinc.org
Other
516 stars 81 forks source link

Feature request: circumvent naming clashes when including models #831

Open Kjarar opened 3 months ago

Kjarar commented 3 months ago

From the docs, emphasis by me:

4.1.5.1. Model Instance Files

MiniZinc models can be constructed from multiple files using include items (see Include Items). MiniZinc has no module system as such; all the included files are simply concatenated and processed as a whole, exactly as if they had all been part of a single file. Rationale: We have not found much need for one so far. If bigger models become common and the single global namespace becomes a problem, this should be reconsidered.

We definitely have a need for that!

Assume you have different models, each complex enough so that different people build different models, and you want to join these models together with some more constraints. How are you supposed to do that with the current naming clash issue? You could force everyone to add a certain, globally unique pre-/suffix to each and every variable, parameter, enum and enum value in their models. But this is not a good solution as it is prone to errors and hinders readability.

If an include could be used inside a let, that would be a solution to the problem. But any other solution would be great as well.