Hacker News new | past | comments | ask | show | jobs | submit login

Is there any convention for denoting which functions in OCaml have side effects?



Not really, but the documentation will usually tell you. Also, at least in Jane Street’a libraries, exceptionful functions always end in _exn. So for example there is List.find and List.find_exn


Some people append `_exn` to names of functions which can raise exceptions; that's about it.


I don't think it's a strict convention, but it's common to see (a block of) imperative statements with side effects enclosed in:

begin ... end

It's ugly and stands out in its awkwardness, almost as if by design, with the compiler saying: "I will let you do this, but do think about it some more and try and come up with something more elegant."


I don't know, I don't write it very much.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: