Skip to content

Distinguish failure to match head from other fault #2429

Answered by UWN
hurufu asked this question in Q&A
Discussion options

You must be logged in to vote

It all depends on what your predicate is about. Is it truly relational? Then go along library(error) must_be/2 and can_be/2.
Currently, your common pattern misses an instantiation error, as ?- foo(G). just sticks to the first clause.

If you issue a domain error, the first argument should be the domain not the observed problem. In general it is better to state with the error what is expected and less what is 'the problem'. See the error classification on how errors are formulated in ISO.

Replies: 4 comments 13 replies

Comment options

You must be logged in to vote
4 replies
@hurufu
Comment options

@hurufu
Comment options

@UWN
Comment options

@hurufu
Comment options

Answer selected by hurufu
Comment options

You must be logged in to vote
5 replies
@UWN
Comment options

@haijinSk
Comment options

@haijinSk
Comment options

@hurufu
Comment options

@haijinSk
Comment options

Comment options

You must be logged in to vote
1 reply
@UWN
Comment options

Comment options

You must be logged in to vote
3 replies
@UWN
Comment options

@hurufu
Comment options

@UWN
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants