Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[OSR] Exceptionless error management, take 2
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-10 (11:58)
From: tab@s...
Subject: Re: [Caml-list] [OSR] Exceptionless error management, take 2
On Fri, Feb 08, 2008 at 07:07:58PM +0000, Jon Harrop wrote:
> On Friday 08 February 2008 09:53:33 Vincent Hanquez wrote:
> > so what's the point in using polymorphics variant then ?
> Brevity:
>   | Xml.Error.Succeed x -> f x
>   | Xml.Error.Failure y -> g y
> vs:
>   | `Succeed x -> f x
>   | `Failure y -> g y
> The alternative is to open the namespace that contains the ordinary variant, 
> which pollutes your namespace will all of its identifiers.
And, I value code readibility more than brevity. in the former case, i
know instantly that what i'm comparing is an Xml error; the later case,
all i know is we compare that either something fail or succeed.

Your option is fine on 100-lines software. it isn't on >= 10K lines

If the brevity is the only "goodness" of using polymorphics variant,
that's particularly ill-advised.

Brevity doesn't apply to symbols btw. If it would, you'll name all your
variables "a" "b" "c" "d" "e" ... not with useful names.

(programming in fortran is over at least in CS)

> As Jacques said, polymorphic variants don't define anything, i.e. don't bind 
> identifiers to type constructors. So they can't pollute anything. The "flat 
> namespace" you refer to doesn't exist.

It defines a "type annotation" that is shared across all your files in
one project. this type annotation is in its own flat namespace, i.e.
using "`x" in file is the same as using "`x" in file
(providing you use the same type with `x obviously)

> This is the same as strings. You would not discourage the use of "foo" in 
> programs because it "pollutes the flat namespace of strings" for the same 
> reason.

except you don't do type checking with strings.

Vincent Hanquez