[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | sejourne_kevin <sejourne_kevin@y...> |
| Subject: | Re: [Caml-list] Re: OCAML Downcasting? |
Marcin 'Qrczak' Kowalczyk wrote:
> skaller <skaller@users.sourceforge.net> writes:
>
>
>>>Attempts to avoid downcasts are often unmodular, they require to
>>>specify all possible variants in one place.
>>
>>It makes no difference. You have do specify them all anyhow,
>>downcast or not.
>
>
> It makes a difference because specifying them at the type definition
> would introduce a dependency loop between modules. And it would be
> unmodular: it would require changing some base module whenever a far
> client module is added.
>
> Apply this reasoning to the exn type. Why don't you define all exn
> constructors in one place?
I think there is no problems with exceptions. But if you have problems
managing exceptions in large modules have you try something like this ?
here an example:
I define all my exceptions like this :
let errors = ref [];;
(*to define an error*)
(*errors "the exception" , the new value*)
errors := ("div by zero" ,0) :: (!errors);;
And the functions catch errors in this way:
let truc () =
try
...
with
... all Ocaml pre-defined exceptions
| exn -> (* my exceptions in errors list ref *)
let s = Printexc.to_string exn in
... Lex & Parse 's' in (fst errors) ref list , then handle error ...
;;
If exceptions are complex I can use polymorphic variants
for the "new value".
-------------------
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