[m-dev.] switching on constant functions
Julien Fischer
juliensf at csse.unimelb.edu.au
Mon Dec 22 15:14:13 AEDT 2008
On Mon, 22 Dec 2008, Ian MacLarty wrote:
> On Mon, Dec 22, 2008 at 12:25:17PM +1100, Julien Fischer wrote:
>>
>> On Mon, 22 Dec 2008, Julien Fischer wrote:
>>
>>>
>>> On Mon, 22 Dec 2008, Ian MacLarty wrote:
>>>
>>>> Hi,
>>>>
>>>> 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.
>>>
>>> What if the type involved is abstract and imported from another module?
>>
>> Obviously the second follows from the first there ;-)
>>
>
> That wouldn't be allowed.
I think you need to make a stronger case for it than this. (A better
description of change, e.g. the proposed change to the reference manual,
would help.)
As it stands, I don't think this is a good idea since it complicates
switch detection, its description of that in the reference manaual,
and consequently makes it harder for users to understand.
Julien.
--------------------------------------------------------------------------
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