Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] exception or conditional
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris GauthierDickey <chrisg@c...>
Subject: [Caml-list] exception or conditional
I'm writing a function that is using an array that can be dynamically 
resized. I'm wondering if it would be better to just catch an exception 
if we attempt to go out of bounds in the array (at which point I resize 
the array), or if I should test the size using an if-then-else before I 
enter the main body of my function and resize then.

How lightweight is the exception mechanism in ocaml? If I test the size, 
then any time I call this function, I have to execute the conditional 
statement. If I use try...with, then I'm entering an exception handling 
block every call to the function. Is one better than the other? Neither 
one makes the code clearer or cleaner, so that's not really a factor.

Thanks in advance for your advice,
Chris G.

-------------------
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