“How hard would it be” to process the mode/type/determinism declarations into executable code, so that I’d get a run-time error if I violated the declarations? I’m guessing that the new “wrapper” facility is sufficient, but there would need to be a change to the parser, to get the %!
comments (there must be a hook for this, but I can’t find it in the docs).
This is implemented by library(pldoc/doc_modes))
, mode/2. You do need to call
:- doc_collect(true).
before loading your code as otherwise PlDoc structured comments are processed as normal comments and thus ignored.
P.s. Please switch topics if you want to continue this
I split the thread into a new topic; hope both of you don’t mind.
Hi Peter,
btw, in Mercury they also have a kind of case construct and the compiler can check if all cases have been covered as per type and non-determinism provided and flag when one or some cases are missing.
Dan
That requires quite a bit of type declaration machinery (which could be a good idea with Prolog, but which doesn’t exist right now); I’ll settle for the Erlang solution of crashing if no clause matches. Unit tests ought to flush those out.
The determinism case is both an efficiency issue (not good to leave unnecessary choice points lying around) but also a correctness one – if the code can backtrack into something I think is deterministic, there’s probably a nasty and difficult to detect latent bug.
The determinism case is both an efficiency issue (not good to leave unnecessary choice points lying around) but also a correctness one – if the code can backtrack into something I think is deterministic, there’s probably a nasty and difficult to detect latent bug.
Good point.
I must have learned something since last year; I would nor have understood your comment a year ago
Dan