Types with SWI-Prolog

I’ve done further experiments and it seems this is a rather effective way to test that determinism expectations are not violated (of course having an exhaustive testsuite).

My remark is that, although to use predicate wrapping is a nice general solution and very useful for debugging complex conditions, I don’t think this it is the right tool for this kind of tracing due to being too much heavyweight. Something integrated with execution (like trace/0 and spy/2) seems a more reasonable choice so to be able to leave determinism check enabled except in the production build.

Concerning the big obstacle of tail call optimization it would be enough to optionally forget the request of pending trace when executing VMI op depart (then relying on a proper determinism check for the called goal).

BTW, noting that O_DEBUGGER stuff is very pervasive also in hot paths I wondered how much gain is obtained compiling the production build with O_RUNTIME, but it seems that such build is rather broken.