Search code examples
minizinc

What does $ mean in MiniZinc?


I see $ used in various places in the MiniZinc Handbook (mostly in the Reference Manual portion), but I haven't been able to find a definition. Would someone kindly explain it to me. Thanks.


Solution

  • MiniZinc supports three basic types, {int, float, bool }. The documentation uses $T as a place-holder for any type contained in this set, so that it is not necessary to provide three versions of each function's signature, one for each basic type.

    I guess that this syntax style is inspired by the shell, where the notation $T is used to dereference the name T and it normally yields the value corresponding to such name/memory location.

    One can also think as $T as a template typename/class in the C++ language, that achieves the exact same purpose.

    // MiniZinc Docs
    set of  $U:    array_union(array[$T]  of     set of  $U)
    
    // C++-like style
    template <class T, class U>
    set<U> array_union(map< T, set<U> >);