Daniel Cabeza Gras says:
In Ciao, unlike in SICStus, there is a clear separation between compile-time actions and run-time actions. The effect of the op/3 declaration applies only at compile-time, and furthermore only to the source where the declaration appears. Thus, in order of making the operator active at run time, you must make a call to the op/3 builtin where appropriate, for example:
Following the Ciao philosophy regarding operators, these belong to the source file where they are used. Thus, it is not "appropriate" to do:
main :- op(950,xfx,'==>'), open('file.pl',read,Stream), read(Stream,A), ...
Instead, the op declaration should be in file.pl
Here is a simple driver that does the thing:
read_clause(Stream,Clause):- read(Stream,Clause), parse(Clause).
parse((:- op(A,B,C))):- !, op(A,B,C). parse(_Clause).
which can be used as follows (in case one does not want to read the op declarations in file.pl):
main :- open('file.pl',read,Stream), read_relevant_clause(Stream,A), close(Stream), write(A), nl.
read_relevant_clause(Stream,A):- repeat, read_clause(Stream,A), + irrelevant(A), !.
irrelevant((:-op(_,_,_))).
Francisco Bueno CLIP group - CS Dept. - FIM - UPM Campus de Montegancedo - 28660, Boadilla del Monte - Madrid Tel: +34 1 336 7448 Fax: +34 1 352 4819 Internet: bueno(a)fi.upm.es http://www.clip.dia.fi.upm.es/~bueno/