4 ms·
I think a lot of programmers use try/catch when what they really want is Prolog-style failure: my_parser(String, Output) :- parseJSON(String, JSON),
by colanderman 15y ago
I think a lot of programmers use try/catch when what they really want is Prolog-style failure:
my_parser(String, Output) :-
parseJSON(String, JSON),
extract_the_values_I_want(JSON, Output).
if my_parser(String, Output) then
...do stuff with Output...
else
...show user "couldn't parse" message...
I've been using Mercury (a strongly typed Prolog) for years now and have never once found the need for exceptions (which Mercury supports) to indicate anything other than catastrophic failure.
- sgt 15y agoWhat are your motivations for using Mercury? Are you using it for hobby projects, research/academic purposes or actual production code?
- colanderman 15y agoHobby projects and hobby research. It has some pretty intense features if you're into type theory. IMO the library support isn't yet there for production code (e.g. no or only rudimental GUI/networking code). But if you're just using it for computation (e.g. AI or compiling or some such) it's pretty solid, and its FFI is the most straightforward I've ever seen. FWIW I hear that these people: http://www.missioncriticalit.com/ http://www.missioncriticalit.com/ and these people: http://www.princexml.com/ http://www.princexml.com/ use it for production code, but I don't know much about them, beyond that Håkom Wium Lie (of CSS and Opera fame) is the Director of the latter. I maintain a blog about Mercury's features for interested users: http://adventuresinmercury.blogspot.com/ http://adventuresinmercury.blogspot.com/ if you're interested.
- sgt 15y agoI'm definitely interested. Thanks. I've now bookmarked your blog.