[mercury-users] How efficient is mercury?

David Overton dmo at cs.mu.OZ.AU
Tue Apr 20 19:20:21 AEST 2004


On Tue, Apr 20, 2004 at 09:07:46AM +0200, Erwan Jahier wrote:
> I don't agree. As long as you do not use " | _ -> " at the end of your
> pattern match, the compiler does check the exhautivity.
> 
> $ocaml
>         Objective Caml version 3.06
> 
> # type foo = | Titi | Toto ;;
> # let f x = match x with Titi -> 1;;
> Warning: this pattern-matching is not exhaustive.
> Here is an example of a value that is not matched:
> Toto
> val f : foo -> int = <fun>

Ah, ok, I had missed noticing those warnings.  It would be nice if you
could ask the compiler to generate an error instead.

> > This makes it much harder to update all affected places if
> > you add an alternative to a discriminated union type.
> >
> > I've gained a new appreciation for the Mercury type checker.  It seems
> > (qualitatively) to be much better at reporting type errors at the point
> > at which the error occurs, rather than giving a confusing message that
> > points to something several lines later.
> 
> I you <<force>> the type (in the Mercury spirit), my experience is that
> compiler points the rigth place 99% of the time.
> 
> You can do it like that:
> 
> 	let (f : int -> float -> 'a -> res) =
> 	fun i f a ->
>   	   ...

Yes, it's true that you can do that, and it's what I've started doing
(and managed to convince others to do) in fact.  However, the language
doesn't exactly encourage that style.

That's probably enough OCaml bashing from me.  I'm actually very happy
to be still using a strongly typed, (mostly) declarative language.  It
sure beats having to use C/C++/C#/Java/VB/etc.


David
-- 
David Overton
WWW: http://www.overtons.id.au/
Mobile Phone (UK): +44 7799 344 322
--------------------------------------------------------------------------
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