[m-dev.] switching on constant functions

Ian MacLarty maclarty at csse.unimelb.edu.au
Mon Dec 22 12:07:55 AEDT 2008


I'd like to be able to switch on the values of constant functions.
For example suppose I have the functions:

    :- func a = (string::(out(bound("a")))).
    :- func b = (string::(out(bound("b")))).

then I'd like to be able to write a switch like:

    % X has inst bound("a" ; "b") before the switch.
        X = a,
        X = b,

Would there be any objections to extending the language to handle this?
If not what would be the best way to implement it?  I was thinking of
replacing constant functions, whose output is an inst with a single
value, by that value before or in the switch detection pass.

The reason I'd like the above feature is that it'd make switches on
strings neater, since we could use a function instead of a (possibly
long) string literal in the switch code.

mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au

More information about the developers mailing list