[m-dev.] try syntax

Peter Wang novalazy at gmail.com
Fri Jan 23 10:56:41 AEDT 2009


On 2009-01-22, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>
> On Thu, 22 Jan 2009, Peter Wang wrote:
>
>> Catching exceptions is too cumbersome.  I think we should have built in
>> syntax, e.g. (adjust accordingly if the parser is too dumb)
>
> I agree too, a similar argument was the reason for replacing
> promise_only_solution with promise_equivalent_solutions scopes.
>
>>    try [io(!IO)] (
>> 	f(X, Y, Z, !IO)
>
> Presumably, this can be some arbitrary goal, not just a call?

Yes.

> Would I be able to do the following:
>
> 	try [io(!IO), store(!S1), store(!S2)] (
> 		f(X, Y, Z, !IO, !S1, !S2)
> 	)
>
> etc ....
> ?

It could be supported in the future but I think, with the existing try*
predicates, we'd have to create mutvars and pass the stores in and out
through those.

> It would be nice if we could avoid (1) having to construct and call
> the closure and (2) having to tuple and untuple the outputs.  I guess
> this could be done by implementing exception handlers in the code generator(s)
> rather than as library predictes?  (It's would almost certainly be a lot
> of work though.)

I don't think try is called enough to justify the effort, and if it is
called that much then you're probably doing something wrong ;-)

It would also be nice if the output variables could be given more
specific insts than `ground'.  This is a real problem right now.
It's a bit hacky but the transformation could insert inst casts after
unpacking the outputs in the success branch.

Peter

--------------------------------------------------------------------------
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