home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: template disappointments ... (suggestions?)
- Message-ID: <1993Jan1.170812.26511@taumet.com>
- Organization: TauMetric Corporation
- References: <24508@alice.att.com> <1hqnd6INNe83@agate.berkeley.edu> <1992Dec30.173230.22878@taumet.com> <1992Dec31.150138.22342@netcom.com>
- Date: Fri, 1 Jan 1993 17:08:12 GMT
- Lines: 31
-
- erc@netcom.com (Eric Smith) writes:
-
- >In article <1992Dec30.173230.22878@taumet.com> steve@taumet.com (Steve Clamage) writes:
- >>In a template instantiation, the 'int' argument might be any expression,
- >>including one containing right shifts. If you try to allow what appears
- >>to be a right shift to be two closing ">" instead, you wind up with
- >>nondeterministic lexing/parsing, ambiguous grammars, or context-sensitive
-
- >How is >> different from > in that respect? a>b is a perfectly valid
- >int expression.
-
- The '>' is always a '>' token. The proposal was that sometimes '>>' is
- a '>>' token and sometimes it is two '>' tokens. The compiler would have
- to decide which interpretation to use. One interpretation might wind up
- being unparseable only after an arbitrary number of additional tokens.
-
- Suppose there are several sets of '>>' in a template expression. Each
- one is a branch point for additional possible parses. The compiler has to
- verify that exactly one of a set of interpretations leads to a valid parse.
-
- A whole new kind of parsing is therefore required just to allow
- programmers to omit a blank between consecutive closing template brackets.
-
- It isn't impossible to have a language like this. The question, as
- always, is whether the additional compiler complexity and other
- disadavantages are outweighed by the advantages. The decision in C
- and C++ has always been to choose context-free lexical analysis and
- the "maximum munch" lexical rule.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-