Version française
Home     About     Download     Resources     Contact us    
Browse thread
[OSR] Exceptionless error management
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: tab@s...
Subject: Re: [Caml-list] [OSR] Exceptionless error management
On Tue, Feb 05, 2008 at 11:26:00AM +0100, Bünzli Daniel wrote:
>> I can see lots of people are concerned by using polymorphic variant (and
>> I certainly agree with those), and people asking for a monadic approch
>> (haskell's either like).
> Still I think this is a little bit sad. Using polymorphic variants isn't 
> that bad at all as long as we just use the following _closed_ type [ `Value 
> of  ... | `Error of ... ].

imho, polymorphic variants ""weaken"" the type system and are a royal PITA
when something is wrong in the code and you need to find it.

for example something plain _stupid_ as:
returning or matching `VAlue instead of `Value

since it will be created "dynamicly" (you don't need to define it), ocaml
will be perfectly happy to return/match it, but you'll have a "weird" error
somewhere else:

# let f x : [`Error | `Value of int ] = if x <= 0 then `Error else `Value x;;
val f : int -> [ `Error | `Value of int ] = <fun>

# let g y = match f y with `Error -> "error" | `VAlue x -> "value"

This pattern matches values of type [< `Error ]
but is here used to match values of type [ `Error | `Value of int ]
The first variant type does not allow tag(s) `Value

with normal variant i'll have a nice error:

	Unbound constructor VAlue

And that's just one thing on the list of 'against' polymorphic variants;
i'm sure people have their own set of bad experiences with polymorphic

> This would allow us to move forward despite that 
> fact that Pervasives is frozen (and no I'm not interested in forking it). 

This is not "forking", for me that's patching.
We _can_ provide the same interface+improvements (no breaking of
previous programs) easily _without_ forking with minimal intrusion as a
patchqueue on top of ocaml stdlib. the compiler might be forbidden
fruit (license, INRIA expertise, etc) and that's probably a bad idea to
fork it anyway, but stdlib should be where we could add major improvement
to the language (a rich and nice stdlib just like all other languages).

Also a proposal that define exceptionless without having the core
library like Hashtbl, Map, Set, List, conforms to this "standard" is
just bound to failure. Either they are modified (bad idea for
compability), Copied+forked into another module (nobody going to use it
+ you're forking some of the stdlib) or the proposal is moot.

> Sure we can have monadic stuff, new types, new infrastructure etc. but I 
> try to design solely within the constraint of the ocaml system as it stands 
> because I know that's something has been there for more than 10 years and 
> continues to be maintained.
> Polymorphic variants have the advantage to 
> allow us to standardize across modules without needing changes to the ocaml 
> system.

they might be standard in ocaml (as in available through the compiler),
but not much library use them.

people should have that in mind when trying to propose them as an OSR;
lots of people are not confortable with them imo.

Vincent Hanquez