[m-rev.] Additions to list.m

Ralph Becket rafe at cs.mu.OZ.AU
Fri Dec 14 10:55:56 AEDT 2001


Nancy Mazur, Thursday, 13 December 2001:
> 
> just out of curiosity.... why is a func version of error
> needed? It seems odd to me... or is there something I'm missing somewhere?

The problem arises when you need to throw an exception from one arm of a
conditional exception.  If you write func bodies as expressions rather
than as a set of goals there's no way to call error/1 in just one of the
branches of a conditional expression.

That is, without func_error/1 you can't write

	f(X) = ( if p(X) then g(X) else error(...) ).

you have to write something like

	f(X) = Y :-
		( not p(X) => error(...) ),
		Y = g(X).

which is a pain.  The problem is exacerbated when your condition tree
has depth greater than one.

Cheers,

Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list