Open aherranz opened 6 days ago
Hi @aherranz. Some declarations, like reexport, do not make sense from the toplevel/REPL/shell. To avoid that it is possible to deactivate that code using conditional compilation as follows:
:- if(defined('SHELL')).
% put here what is required in a toplevel (it can be empty)
:- else.
% and here what cannot run in a toplevel
:- endif.
for example:
:- if(defined('SHELL')).
:- else.
:- reexport(library(rfuzzy/rfuzzy_rt)).
:- endif.
Another issue is whether reexport for a package is really required (usually we never need it but I'm not familiar with rfuzzy).
Let us know if you need to modify the goal expansion when run in a toplevel context. This is also possible but not really well documented.
But reexport is not being used from the REPL, in the interpreter I am just doing use_package(rfuzzy).
The reexport is in the main module of the library.
I am not familiar with the implementation of rfuzzy, I am just trying to use it. Thanks for your orientation.
Actually doing a use_package
from the toplevel inserts the package contents, like an include. Thus adding the conditional compilation to the rfuzzy
package source will fix that problem.
Edit: More details on this. Packages in Ciao are not really modules, but source files that are directly included in the context the use them. Most of the time, the source is a collection of directives like use_module
, other use_package
, some operator definitions, and other directives to enable user-defined code expansions (like add_sentence_trans
). This modified rfuzzy.pl
package may fix the issues with reexport in a toplevel:
:- package(rfuzzy).
:- use_package(hiord).
:- use_module(library(rfuzzy/rfuzzy_rt)).
:- if(defined('SHELL')).
:- else.
:- reexport(library(rfuzzy/rfuzzy_rt)).
:- endif.
:- use_module(library(aggregates), [findall/3]).
:- use_module(library(terms),[copy_args/3]).
:- use_module(engine(basic_props), [list/1]).
:- include(library(rfuzzy/rfuzzy_ops)).
:- load_compilation_module(library(rfuzzy/rfuzzy_tr)).
:- add_sentence_trans(rfuzzy_tr:rfuzzy_trans_sentence/3, 730).
I am loading the rfuzzy package and I get an error message "reexport/1 directive not allowed in shell"
The main module of the library is this one:
I don't know the implication of the error, I am not sure if predicates are reexported or not. Can I avoid such a message? (I can update the rfuzzy library).
Regards.