[mercury-users] Again exceptions (patternmatch & devide-by-zero)

xkb at hypernation.net xkb at hypernation.net
Wed Dec 4 20:27:56 AEDT 2002


I dont't know if merucry supports pattern matching, though I think it does.

Pattern matching is often used in functional programming languages to offer case
distinction.

An example from Haskell:

f :: Int -> Int
f x =
 | 0 = Error(0)
 | >0 = 10/x

Let assume someone would call f(-10), as the patterns indicated by the |'s are
not exhaustive, an error will occur: Pattern match not exhaustive. Does this
kind of behaviour throw an exception in mercury?

Quoting Peter Ross <pro at missioncriticalit.com>:

> sander wrote:
> > I looked at the implementation of Mercury using the CVS checkout. I was
> > looking for the use of exceptions in the integer.m files and in
> > pattern-matching in general. However, I could not find it. Did I
> > overlook?
> >
> For historical reasons, we use error/1 to report most errors.  error/1 is
> located in require.m and you will see that it is implemented as a throw.
> 
> I am not sure what you mean by pattern matching, maybe more of an
> explaination is required.
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.423 / Virus Database: 238 - Release Date: 26/11/2002
> 
> --------------------------------------------------------------------------
> 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
> --------------------------------------------------------------------------
> 
> 




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
--------------------------------------------------------------------------
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