There is a 32000 character limit for post that is inherited from the DB size of a field. It can be changed but we don’t. So another reply is added to continue the collection of knowledge.
From Jan W. (ref)
Without really answering your question, did you discover the SSU rules (Head => Body) and det/1? Since I use those, debugging time has been reduced a lot. Other recent goodies are trap/1 and gtrap/1 to quickly get the debugger at an exception. And of course, there is check/0 to do some static analysis, be it a lot less than mercury. And, last but not least the new “sweeprolog” mode for GNU emacs or the built-in Emacs clone save you a lot of work.
For creating a test case that mocks an external resourceby Jan W. (ref)
There is nothing out of the box. There are lots of options though. For example, implement a mock version of the library that calls the external service and load it instead of the real thing by changing the (library) search path. You can also use wrap_predicate/4 to create a wrapper around any predicate. That is intended to call the original, but of course you don’t need to. You can even abolish/1 the old predicate and assert a new definition.
None of that is portable. Wrapping predicates is really SWI-Prolog specific. There is no portability in search path handling (but many systems have it) and ISO turned
abolish/1
into something useless because you can only use it on dynamic code where, in addition toretractall/1
, it removes the predicate properties (dynamic, etc.) SWI-Prolog kept the pre-ISO semantics where abolish/1 applies to any predicate.Than you need an alternative implementation for the external server. I don’t know how much you can generalize that. I guess it can be anything.
Per Jan W. ([ref](https://Note that for indexing, atoms are faster than strings as atoms just look at the handle and strings actually need to access the text.))
Note that for indexing, atoms are faster than strings as atoms just look at the handle and strings actually need to access the text.