Article View: comp.lang.prolog
Article #4104Re: Prefix operators and blanks (was: WG17)
From: Mats Carlsson
Date: Wed, 06 Dec 1989 08:50
Date: Wed, 06 Dec 1989 08:50
44 lines
2616 bytes
2616 bytes
In article <24703@cup.portal.com> pgl@cup.portal.com (Peter G Ludemann) writes:
If one decides to define 'not' as a prefix operator and also
chooses to use it with as a functor (e.g. `not(a,b)'), one is
asking for trouble and should instead disambiguate by extra
quote marks or parentheses: 'not'(a,b) or not((a,b)).
I therefore suggest that the Prolog standard specifically
disallow using a prefix operator as a functor.
But what about prefix operators that are atoms that need quoting?
Disallowing them altogether seems a rather severe restriction. If
they are allowed, quotes cannot be used for the disambiguating rule in
the first paragraph. Are you suggesting that an extra pair of
parentheses would be required in that case?
Peter's suggestion would have an impact on the canonical syntax of
Prolog. I don't have the WG17 draft handy, but I can't imagine that
it fails to define a canonical syntax which is independent of any
operator declarations that happen to be declared, so that a printed
term can always be read back in. Many Prologs provide
write_canonical/[1-2] as built-in predicates exactly for this purpose.
With Peter's suggestion ALL functors would have to be printed with
quotes in the canonical syntax, e.g.
'f'(1,2).
to cater for the case that it might be read in with 'f' declared as a
prefix operator.
The idea of letting quotes influence how terms are parsed seems to
blur the distinction between lexical and syntactical analysis. It
seems cleaner to treat quotes strictly at the lexical level. The only
other language where "atoms" can be quoted that I know of is LISP, but
LISP does not have user defined operators, so it's hard to find an
analogy to justify Peter's suggestion.
Another way of avoiding the ambiguity with `not(a,b)', `not (a,b)',
... (assuming spaces before the `(' are no longer significant) would
be to simply disallow the use of `,' as an infix operator.
--
Mats Carlsson
SICS, PO Box 1263, S-164 28 KISTA, Sweden Internet: matsc@sics.se
Tel: +46 8 7521543 Ttx: 812 61 54 SICS S Fax: +46 8 7517230
Technical Details
Message-ID:
<MATSC.89Dec6095053@vishnu.sics.>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!brutus.cs.uiuc.edu!apple!motcsd!hpda!hpcuhb!hpsmtc1!hp-ses!hplabs!hp-sdd!ncr-sd!ncrcae!hubcap!mephisto!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcsun!sunic!sics.se!sics.se!matscReferences:
<24703@cup>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!brutus.cs.uiuc.edu!apple!motcsd!hpda!hpcuhb!hpsmtc1!hp-ses!hplabs!hp-sdd!ncr-sd!ncrcae!hubcap!mephisto!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcsun!sunic!sics.se!sics.se!matsc From: matsc@sics.se (Mats Carlsson) Newsgroups: comp.lang.prolog Subject: Re: Prefix operators and blanks (was: WG17) Message-ID: <MATSC.89Dec6095053@vishnu.sics.> Date: 6 Dec 89 08:50:00 GMT References: <24703@cup> Lines: 44