This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Make parser revert digraph "<:"


"Zack Weinberg" <zack@codesourcery.com> writes:

| Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
| 
| > "Giovanni Bajo" <giovannibajo@libero.it> writes:
| >
| > | Hello Mark,
| > | 
| > | this patch makes the parser aware that "<:" is a digraph for "[". In other
| > | words, if the parser sees "A[:0>", where A is a template, it will parse it as
| > | "A< ::0>", and will emit the following diagnostic:
| > | 
| > | error: template parameter list is invalid because `<:' is a digraph for `['
| > | note: use `< ::' to avoid forming the digraph
| >
| > I would rather see the diagnostic as
| >
| >   error: check the spelling of the template-argument list; '<:' is a
| >     digraph (another spelling for '[').  Insert a whitespace between
| >     '<' and '::'.
| 
| While this diagnostic is technically more accurate, I think it's both
| more confusing and poorer English.  How's this?
| 
| error: '<::' cannot begin a template-argument list

The confusing thing about this suggestion is that the beginning of the
template-argument list is not '<::'.  It is like writing

    +++i

which gets lexed as ++ + i and not + ++ i.  How would you phrase  the
diagnostic for that?
 
| note: '<:' is an alternate spelling for '[', insert whitespace 
|       between '<' and '::'
| 
| (I moved all of the verbose explanation to the note: because I want a
| -fno-explanations mode in which all inform() calls do nothing, for
| people who have seen it all before and don't need to hear it again.)

I fully agree with that suggestion.  

| (I wonder if anyone will request a do-what-I-mean mode, in which this
| and other places where template syntax clashes with greedy tokenization
| are all parsed the way the programmer 'obviously' meant?)

Yes, that is one of the items on the C++ Evolution Working Group wishlist
we would like to address as cleanly as possible.  Also, see suggestion
ES018 at

    http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1512.html

for things like

    vector<list<int>> vl;

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]