Topic: Core Issue 968 / N3034 (Disambiguating [[ )
Author: Fabio Fracassi <f.fracassi@gmx.net>
Date: Thu, 4 Mar 2010 11:06:04 CST Raw View
The proposed solution for this Issue ( to use the max-munch principle
for the sequence [ [ ) seems to lead to exactly the same problem that C
++0x just got rid of with >> in templates, i.e. the examples from
N3034:
int p[10];
void f() {
int x = 42;
int(p[[x]{return x;}()]); // Error: malformed attribute on a nested
// declarator-id and not a
function-style cast of
// an element of p.
new int[[]{return x;}()]; // Error even though attributes are not
allowed
} // in this context.
would become legal (and useful) code with introduced spaces:
int(p[ [x]{return x;}()]);
new int[ []{return x;}()];
or am I mistaken?
If I am not won't that introduce the same "minor, but persisting,
annoying, and somewhat embarrassing problem" that n1757 solves for
right angle brackets?
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Sean Hunt <rideau3@gmail.com>
Date: Fri, 5 Mar 2010 12:05:53 CST Raw View
On Mar 4, 10:06 am, Fabio Fracassi <f.fraca...@gmx.net> wrote:
> The proposed solution for this Issue ( to use the max-munch principle
> for the sequence [ [ ) seems to lead to exactly the same problem that C
> ++0x just got rid of with >> in templates, i.e. the examples from
> N3034:
>
> int p[10];
> void f() {
> int x = 42;
> int(p[[x]{return x;}()]); // Error: malformed attribute on a nested
> // declarator-id and not a
> function-style cast of
> // an element of p.
> new int[[]{return x;}()]; // Error even though attributes are not
> allowed
>
> } // in this context.
>
> would become legal (and useful) code with introduced spaces:
>
> int(p[ [x]{return x;}()]);
> new int[ []{return x;}()];
>
> or am I mistaken?
> If I am not won't that introduce the same "minor, but persisting,
> annoying, and somewhat embarrassing problem" that n1757 solves for
> right angle brackets?
No; the proposal prohibits the use of two consecutive [ tokens other
than to introduce an attribute. This is not a tokenization issue like
">>" was. Any amount of interior whitespace will make no difference. In
order to make the code legal, the lambda would have to be wrapped in
parentheses:
int (p[([x]{return x;}())];
Sean
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Fabio Fracassi <f.fracassi@gmx.net>
Date: Sun, 7 Mar 2010 21:39:28 CST Raw View
On 5 Mrz., 19:05, Sean Hunt <ride...@gmail.com> wrote:
> On Mar 4, 10:06 am, Fabio Fracassi <f.fraca...@gmx.net> wrote:
> > ... won't that introduce the same "minor, but persisting,
> > annoying, and somewhat embarrassing problem" that n1757 solves for
> > right angle brackets?
>
> No; the proposal prohibits the use of two consecutive [ tokens other
> than to introduce an attribute. This is not a tokenization issue like
> ">>" was. Any amount of interior whitespace will make no difference. In
> order to make the code legal, the lambda would have to be wrapped in
> parentheses:
>
> int (p[([x]{return x;}())];
>
> Sean
>
Which is also quite surprising, isn't it? And a similar embarrassment
while teaching C++? Well I guess it can't be helped.
regards
Fabio
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Sean Hunt <rideau3@gmail.com>
Date: Mon, 8 Mar 2010 09:40:43 CST Raw View
On Mar 7, 8:39 pm, Fabio Fracassi <f.fraca...@gmx.net> wrote:
> Which is also quite surprising, isn't it? And a similar embarrassment
> while teaching C++? Well I guess it can't be helped.
>
> regards
>
> Fabio
Having implemented the lookahead in clang, I can tell you it's not a
big deal (just scan ahead to the next ], taking nesting into account,
and see if it's followed by another one); I'm not a big fan of this
proposal myself.
Sean
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Fabio Fracassi <f.fracassi@gmx.net>
Date: Tue, 9 Mar 2010 05:25:33 CST Raw View
On 8 Mrz., 16:40, Sean Hunt <ride...@gmail.com> wrote:
> On Mar 7, 8:39 pm, Fabio Fracassi <f.fraca...@gmx.net> wrote:
>
> > Which is also quite surprising, isn't it? And a similar embarrassment
> > while teaching C++? Well I guess it can't be helped.
>
> > regards
>
> > Fabio
>
> Having implemented the lookahead in clang, I can tell you it's not a
> big deal (just scan ahead to the next ], taking nesting into account,
> and see if it's followed by another one); I'm not a big fan of this
> proposal myself.
>
> Sean
>
> --
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use
> mailto:std-...@netlab.cs.rpi.edu<std-c%2B...@netlab.cs.rpi.edu>
> ]
> [ --- Please see the FAQ before posting. --- ]
> [ FAQ:http://www.comeaucomputing.com/csc/faq.html ]
I wouldn't know, since I have only theoretical knowledge regarding
compilers/parsers. I hope that your experience does count though and
makes the committee reconsider this proposal, and allow the
unsurprising syntax (i.e. int (p[[x]{return x;}()]; )
Regards
Fabio
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]