Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] GC and file descriptors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] GC and file descriptors
On Wed, 19 Nov 2003, Martin Berger wrote:

> imagine having 100000 lines of code, mostly mature, and you are trying to
> track down a little bug. for that you want to see with what arguments the
> function
> 
>     let f m n =
>        body;;
> 
> is called. assume that function has the type
> 
>     f : int -> ( int -> A throws E ) throws E
> 
> so for debugging you modify f to
> 
>     let f m n =
>        print_debug "calling f with arguments " m n;
>        body
> 
> if print_debug may throw something not in E and if f is used all over
> your code, you will have make an enourmous of changes (and later revert
> them) just to get a silly little debugging mechanism going. i would hate
> having to do this.  being able to switch off exception would be a great
> help in this situation.

If calling print_debug adds an error condition (i.e. can throw an 
exception), then you have two choices:
1) Fix print_debug so it doesn't throw an exception,
2) Do the following instead:

let f m n =
	try print_debug "calling f with arguments " m n with _ -> ();
	body

I'd recommend #1 myself.  Debugging code should not have any effect on the 
program (otherwise, you are opening yourself up to heisenbugs, where the 
program works correctly with debugging turned on, and fails with debugging 
turned off).

> 
> being able to switch on or off exception checking is just an instance of
> a more general phenomenon where you run different checks on your software
> independently of each other. i expect future compilers to be more flexible
> in this regard, maybe offering plug-in typing systems from untyped to
> fully fledged dependent types and proof annotations.
> 

The problem with this is that then everyone immediately turns exception 
checking off and the value of the feature is greatly reduced (at best).

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners