Article View: comp.lang.prolog
Article #1554Re: postfix operators - does anyone need them?
From: Richard A. O'Keefe
Date: Tue, 06 Oct 1992 12:07
Date: Tue, 06 Oct 1992 12:07
65 lines
3426 bytes
3426 bytes
In article <1992Sep30.205620.5130@quintus.com>, pds@quintus.com (Peter D. Schachte) writes:
> I haven't seen any formal proposals for a distfix extension; does anyone
> have one?
The DEC-10 Prolog library contains a file DISTFI.PL which is a Prolog
parser adapted from READ.PL and supporting distfix operators. It is
based loosely on CGOL and was written to support a functional language
that was implemented on top of DEC-10 Prolog. There should still be a
copy in the Edinburgh Prolog library, and there ought to be a copy at
Quintus. The basic idea was to extend op declarations:
distfix_op(Priority, [{x,y}]f[{x,y}], List, Term)
the x or y on the left refers to an operand preceding the first keyword;
the x or y on the right refers to an operand following the last keyword;
I forget about the internal operands but they were probably 999 or x.
e.g. distfix_op(950, fy, [if,A,then,B,else,C],
if_then_else(A,B,C)).
I never got around to writing an unparser.
> Does it support required and optional term parts?
In a way. Just like WonderPop on the dear old DEC-10, you can have
any number of distfix declarations for the same leading keyword. So
you can have
distfix_op(950, fy, [if,A,then,B],
if_then_else(A,B,true)).
A "required" part is just a part common to all the patterns.
An optional part is a part which is not common to all the patterns.
> Repeated parts?
No.
> What kind of flexibility does it give users to control the
> structure of the (sub)term ultimately returned?
Shown above.
> It seems to me like a hard problem to design such an extension.
No. Remember, WonderPop had the "forms" facility which was a way of
letting Pop programmers specify new keyword-based forms, e.g.
form for I: ident in E: expr do S: stmts enddo;
map(lambda I; S end, E)
endform;
might define iteration over a list. There was also the CGOL parser to
look at (the Edinburgh DAI library had a copy of a paper by Pratt which
made it very clear) and there were people around working with functional
languages who wanted it. My DISTFIX.PL was deemed adequate at the time,
but of course syntax error handling was dismal and unparsing wasn't
implemented at all. It's also worth pointing out that READ.PL and
DISTFI.PL are written in Prolog. The distfix reader could backtrack all
over the place, it was _not_ a deterministic parser. If you want to
design a distfix extension which is easy to parse deterministically,
that's another matter. (It has been done, though. Ask in comp.compilers
about compilers with run-time-extensible syntax.)
--
RMIT policy requires the use of Gender Inclusive Language in all publications
and in all information conveyed to students, staff, and potential job
applicants. Lapses into English are the sole responsibility of the author.
The Constitution of Australia does _not_ guarantee Freedom of Speech.
Technical Details
Message-ID:
<14917@goanna.cs.rmit.oz.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!munnari.oz.au!bruce.cs.monash.edu.au!goanna!okReferences:
<BusC69.MpE@gabriel.keele.ac.uk> <CHIK.92Sep22103654@ss38.icot.or.jp> <1992Sep30.205620.5130@quintus.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!munnari.oz.au!bruce.cs.monash.edu.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: postfix operators - does anyone need them? Message-ID: <14917@goanna.cs.rmit.oz.au> Date: 6 Oct 92 12:07:10 GMT References: <BusC69.MpE@gabriel.keele.ac.uk> <CHIK.92Sep22103654@ss38.icot.or.jp> <1992Sep30.205620.5130@quintus.com> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 65