caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Run time error on exception
@ 2018-01-31 21:14 Lorenzo Pomili
  2018-01-31 21:35 ` Yawar Amin
  2018-02-01  7:10 ` Malcolm Matalka
  0 siblings, 2 replies; 6+ messages in thread
From: Lorenzo Pomili @ 2018-01-31 21:14 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1059 bytes --]

Friend of mine, pointed out to me a case in Reason who cause no compile
time error but run time error, I had reimplemented similar case in OCaml:



exception Generic_exc;;

let string_of_string s = string_of_int (int_of_string s)

let foo = string_of_string "foo"

let fun_exeption x =
    match x with
    0 -> 0
    | _ -> raise Generic_exc
;;

let bar = string_of_int (fun_exeption 5)



both foo and bar don't fail at compile time fail at run time, me and my
friend also try to reimplement similar case (the first one with string and
int) in Elm, and Elm compiler just say you have to manage exeption, because
function can actualy return exeption instead of int.

There is a compile params or similar for check this kind of error? is a
side effect of have a multi-paradigm? and if is it, how to manage it?

I belive I can use OCaml in functional way without just making attention to
not use side effect but if use of function like int_of_string can make run
time error, I probably approac to OCaml in wrong way, and I wanna
understand how to correct it.

[-- Attachment #2: Type: text/html, Size: 1186 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-05 15:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31 21:14 [Caml-list] Run time error on exception Lorenzo Pomili
2018-01-31 21:35 ` Yawar Amin
2018-02-01  7:10 ` Malcolm Matalka
2018-02-04 18:14   ` Lorenzo Pomili
2018-02-05 10:49     ` Malcolm Matalka
2018-02-05 15:26     ` Yawar Amin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).