5 ms·
One reason could be having oop-style objects available in Prolog. Prolog modules are global, they’re like a singleton, or like s bunch of namespaced functions.
by rad_gruchalski 4y ago
One reason could be having oop-style objects available in Prolog. Prolog modules are global, they’re like a singleton, or like s bunch of namespaced functions. Once you import a module, it is like a singleton. Prolog doesn’t have anything what could store a state of a module so functions inside of a module can operate on some common state. One way would be to use a global database but that’s really discouraged because of performance impact it can have.
Modules being a Prolog construct can be basically created at runtime. So if you need multiple instances, you could create and load multiple modules at runtime. But that’s pretty verbose and quite a bit of work.
Logtalk gives you this out of the box using your standard Prolog.
- harperlee 4y agoI think one of the use cases for lambda-prolog (a prolog for higher-level logic instead of first-level logic) was the ability to implement modules in a logical-native way.