[mercury-users] false function

Richard A. O'Keefe ok at cs.otago.ac.nz
Wed Jul 30 13:13:14 AEST 2003


There's one thing badly wrong with

	foo(X) =
	   ( if bar(X) then
	      value1
	   else if baz(X) then
	      value2
	   else
	      false
	   ).
	
which is that the value of the function is _not_ "false", there is no value
in that case.  I've seen \Omega (an actual Omega) used for this purpose and
(error "string") in a language without "semidet functions" and _|_ (as an
approximation to the symbol for bottom).  One nice notation for an undefined
value goes back to BCPL: "?".  Perhaps the best notation would be simply to
drop the "else" branch and write

	foo(X) = (if bar(X) then value1
	     else if baz(X) then value2).

By the way, I don't suppose there's any possibility of "infix if" is there?

	foo(X) = (value1 if bar(X) else
	          value2 if baz(X)).

Thought not.  Pity.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list