On 30/05/2014 01:14, Travis Johnson wrote: > Hi Joachim! > > What does the "_at_Module" statement do? It overrides the "context module". Some predicates are sensitive to the module context from which they are called, essentially because in different module different things (predicates, etc) are visible. For example, compile_term([p:-writeln(hello)]) will create a predicate p/0 which is local to the module from which compile_term/1 was called. If you wanted to create the predicate in a different module, you would use compile_term([p:-writeln(hello)])_at_SomeOtherModule. Related to this is the tool-declaration, which allows you to write our own predicate that knows from which module context it was called: > :- tool(dynamic_to_static/1, dynamic_to_static_/2). > dynamic_to_static_(F/N, Module) :- > functor(Head, F, N), > findall(Head:-Body, clause(Head, Body), Clauses)_at_Module, > abolish(F/N)_at_Module, > compile_term(Clauses)_at_Module. Here, the system maps any call to dynamic_to_static/1 into a call to dynamic_to_static_/2 by adding the call's context module as an extra argument. You can then use this module for _at_Module annotations where needed. If all your code were in the same module (including dynamic_to_static/1 itself), you wouldn't need any of this. I just wanted to show a piece of code general enough to go into a utilities library. The overview of the module system is here http://www.eclipseclp.org/doc/userman/umsroot037.html Cheers, JoachimReceived on Fri May 30 2014 - 18:02:03 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST