home *** CD-ROM | disk | FTP | other *** search
- From: kers@hplb.hpl.hp.com (Chris Dollin)
- Date: Wed, 9 Sep 1992 08:21:35 GMT
- Subject: Re: Scientists as Programmers (was Re: Small Language Wanted)
- Message-ID: <KERS.92Sep9092135@cdollin.hpl.hp.com>
- Organization: Hewlett-Packard Laboratories, Bristol, UK.
- Path: sparky!uunet!spool.mu.edu!sdd.hp.com!hpscdc!scd.hp.com!hplextra!otter.hpl.hp.com!hpltoad!cdollin!kers
- Newsgroups: comp.edu
- References: <1992Sep3.112944.20996@dbsun.uucp> <Bu08uF.HBC@mentor.cc.purdue <KERS.92Sep4154056@cdollin.hpl.hp.com> <135691@lll-winken.LLNL.
- Distribution: na
- Sender: news@hplb.hpl.hp.com (Usenet News Administrator)
- Followup-to: comp.lang.misc
- Lines: 48
- In-Reply-To: blair@lll-crg.llnl.gov's message of 8 Sep 92 16:08:19 GMT
- Nntp-Posting-Host: cdollin.hpl.hp.com
-
- In article ... blair@lll-crg.llnl.gov (Gary Blair) writes:
-
- In article ... kers@hplb.hpl.hp.com (Chris Dollin) writes:
- >In article ... fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
- >
- > C++ allows you to overload existing operators, although to make compiler
- > writer's jobs easier, it does not allow you to introduce new operators.
- >
- >Make that ``trivially easier''. So far as I am able to tell, the
- >difficulty of allowing the user to add new operator definitions is rather
- >close to zero, so long as this is taken into account *before* designing
- >the language and compiler. (C++ has the problem of trying to incorporate
- >the lexical structure of C.)
-
- Wrong. If your compiler uses ANY kind of table-driven parsing scheme, it is
- next to impossible to allow programmer-defined operators. The parser must
- know what an operator looks like, and what precedence it has with respect
- to all other operators. This is usually predetermined, at
- compiler-generation time.
-
- Well, in that case there are several next-to-impossible compilers out there,
- all compiling Algol68. And, depending on what you mean by ``table-driven
- parsing'', ``next-to-impossible'' is a gross over-statement. All it takes is
- feedback from the semantic analysis to the lexical analyser, telling it what
- the current precedence of operator tokens is. You may have religious objections
- to this technique; I know I do.
-
- But in any case, the difficulty lies with *precedence*, not *spelling* (the
- latter being ``knowing what an operator looks like''). If you're prepared to
- give user-defined operators a fixed precedence level, then the problem goes
- away. I'd rather have user-defined operators with a fixed precedence level
- (assuming the designer is sane enough to choose a sensible value) than not have
- them at all.
-
- As for the parser knowing what an operator looks like, it has the same problem
- as knowing what an indentifier looks like, or a string, or a keyword; to wit,
- none. Assuming, that is, that you construct operator symbols from an alphabet
- of operator characters in a uniform way -- just as identifier symbols are
- constructed from identifier characters (usually letters, digits, and the odd
- special character).
-
- Now I've exposed my hidden assumptions, you mat accuse me of cheating.
-
- [I've adjusted followups to comp.lang.misc. I hope.]
- --
-
- Regards, | "You're better off not dreaming of the things to come;
- Kers. | Dreams are always ending far too soon." - Caravan.
-