When to fail and when to throw exceptions?

Discussion on the revision of the current Core standard

Moderator: Paulo Moura

When to fail and when to throw exceptions?

Postby v » Fri Mar 21, 2008 2:31 pm

Should atom_codes(compound(term), X) fail or throw an exception?
I find failing more useful.. maybe there should be a flag to turn exceptions into failure?
v
 
Posts: 3
Joined: Fri Mar 21, 2008 11:46 am

Re: When to fail and when to throw exceptions?

Postby Paulo Moura » Fri Mar 21, 2008 3:48 pm

v wrote:Should atom_codes(compound(term), X) fail or throw an exception?

The ISO Prolog standard mandates a type_error/2 exception in this case.
v wrote:I find failing more useful.. maybe there should be a flag to turn exceptions into failure?

If you want to turn an exception into a failure we can do it easily using catch/3.

Cheers,

Paulo
Paulo Moura
Logtalk developer
Paulo Moura
Site Admin
 
Posts: 18
Joined: Sun May 13, 2007 11:32 am
Location: Portugal


Return to Core Revision

Who is online

Users browsing this forum: No registered users and 1 guest

cron