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
[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: 2004-02-10 (23:07)
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 Archives:
Bug reports: FAQ:
Beginner's list: