Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!howland.reston.ans.net!Germany.EU.net!Munich.Germany.EU.net!ecrc!news
From: joachim@ecrc.de (Joachim Schimpf)
Subject: Re: Proposal: Extension to operator syntax
Message-ID: <D5spEM.Aro@ecrc.de>
Sender: news@ecrc.de
Reply-To: joachim@ecrc.de
Organization: European Computer-Industry Research Centre GmbH, Munich, Germany
References: <3kki6i$42t@prakinf2.PrakInf.TU-Ilmenau.DE>
Date: Tue, 21 Mar 1995 14:54:21 GMT
Lines: 46

In article 42t@prakinf2.PrakInf.TU-Ilmenau.DE, huebner@gaia.PrakInf.TH-Ilmenau.DE (Huebner) writes:
>...
>it would be nice to have an extension to the operator syntax of prolog,
>that would allow an operator to consist of more than one keyword.
>Maybe something like this:
>
>check_conditional( Globals, my_syntax( if Bool_Exp then Then_Exp else Else_Exp end ) ) :-
>  check_boolean( Globals, Bool_Exp ),
>  check_expression( Globals, Then_Exp ),
>  check_expression( Globals, Else_Exp ).
>
>To tell the consult procedure the special syntax it should be sufficient to write:
>
>:- op( my_syntax, 100, fxfxfxf, if then else end ).
>


Have a look at distfix.pl in the public domain DEC-10 Prolog library.
This can do the following:

[eclipse 1]: use_module(library(distfix)).

yes.
[eclipse 2]: distfixop(100, fx, [if,Bool_Exp,then,Then_Exp,else,Else_Exp,end],
	ifthenelse(Bool_Exp,Then_Exp,Else_Exp)).

yes.
[eclipse 3]: read(Term, Vars).
	if X>0 then p else q end.

Term = ifthenelse(Var > 0, p, q)
Vars = ['X' = Var]
yes.


The library is distributed together with ECLiPSe and possibly other Prolog
systems, or available e.g. from
ftp://src.doc.ic.ac.uk/computing/programming/languages/prolog/pd-software/tools.tar.Z


---------------------------------------------------------------------------
 Joachim Schimpf                                 Email   joachim@ecrc.de 
 European Computer-Industry Research Centre      Phone   +49 89 92699 111
 Arabellastrasse 17, D-81925 Munich, Germany     Fax     +49 89 92699 170


