unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
@ 2016-08-10  9:38 Arash
  2016-08-10 22:07 ` Robert Cochran
  2016-08-11 12:14 ` Alan Mackenzie
  0 siblings, 2 replies; 8+ messages in thread
From: Arash @ 2016-08-10  9:38 UTC (permalink / raw)
  To: 24195

$ emacs -Q test.cc

bool test()
{
    return \
        a() <= b() &&
        c() >= d() &&
        e() == f() &&
        g() != h() &&
        i() >  j() &&
        k() <  l() &&
               m() == n() // !!!
        ;
}





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
  2016-08-10  9:38 bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode) Arash
@ 2016-08-10 22:07 ` Robert Cochran
  2016-08-11 12:14 ` Alan Mackenzie
  1 sibling, 0 replies; 8+ messages in thread
From: Robert Cochran @ 2016-08-10 22:07 UTC (permalink / raw)
  To: Arash; +Cc: 24195

I can comfirm; error is still present on emacs-25 branch @ commit f785ff4
-- 
~Robert Cochran

GPG Fingerprint - E778 2DD4 FEA6 6A68 6F26  AD2D E5C3 EB36 4886 8871





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
  2016-08-10  9:38 bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode) Arash
  2016-08-10 22:07 ` Robert Cochran
@ 2016-08-11 12:14 ` Alan Mackenzie
  2016-08-12 15:26   ` Noam Postavsky
  1 sibling, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2016-08-11 12:14 UTC (permalink / raw)
  To: Arash; +Cc: 24195

Hello, Arash.

On Wed, Aug 10, 2016 at 02:08:52PM +0430, Arash wrote:
> $ emacs -Q test.cc

> bool test()
> {
>     return \
>         a() <= b() &&
>         c() >= d() &&
>         e() == f() &&
>         g() != h() &&
>         i() >  j() &&
>         k() <  l() &&
              ^
>                m() == n() // !!!
>         ;
> }

Yes.  In the line "k() < l() &&", the "<" is being recognised as a
template opener.

The syntax of C++ is ambiguous, and it is difficult for anything which
isn't a compiler reliably to distinguish between "less than" and "open
template" in circumstances like that.  It was easier for earlier
versions of C++, where the "&&" operator wasn't valid inside a template.

I'm not sure I can do very much to help, here.  Even waiting on the
closing ">" before recognising a template wouldn't help much, because
you're just as likely to have the line with "<" before the line with
">".

There are crude workarounds, like writing "!(k() >= l()), but that's
horrible.

So, sorry and all that, I don't think I can do anything to fix this.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
  2016-08-11 12:14 ` Alan Mackenzie
@ 2016-08-12 15:26   ` Noam Postavsky
  2016-08-12 16:56     ` Andreas Schwab
  0 siblings, 1 reply; 8+ messages in thread
From: Noam Postavsky @ 2016-08-12 15:26 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Arash, 24195

On Thu, Aug 11, 2016 at 8:14 AM, Alan Mackenzie <acm@muc.de> wrote:
> Yes.  In the line "k() < l() &&", the "<" is being recognised as a
> template opener.

Is it possible to say that "<" can't be a template opener when it
comes after a close paren? (I can't think of a case in C++ where that
would fail, though I'm not 100% certain there isn't one)





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
  2016-08-12 15:26   ` Noam Postavsky
@ 2016-08-12 16:56     ` Andreas Schwab
  2016-08-18 12:11       ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2016-08-12 16:56 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Alan Mackenzie, Arash, 24195

On Aug 12 2016, Noam Postavsky <npostavs@users.sourceforge.net> wrote:

> On Thu, Aug 11, 2016 at 8:14 AM, Alan Mackenzie <acm@muc.de> wrote:
>> Yes.  In the line "k() < l() &&", the "<" is being recognised as a
>> template opener.
>
> Is it possible to say that "<" can't be a template opener when it
> comes after a close paren? (I can't think of a case in C++ where that
> would fail, though I'm not 100% certain there isn't one)

operator()<foo>

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
  2016-08-12 16:56     ` Andreas Schwab
@ 2016-08-18 12:11       ` npostavs
  2016-08-22 11:08         ` Alan Mackenzie
  0 siblings, 1 reply; 8+ messages in thread
From: npostavs @ 2016-08-18 12:11 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Alan Mackenzie, Arash, 24195

Andreas Schwab <schwab@linux-m68k.org> writes:

> On Aug 12 2016, Noam Postavsky <npostavs@users.sourceforge.net> wrote:
>
>> On Thu, Aug 11, 2016 at 8:14 AM, Alan Mackenzie <acm@muc.de> wrote:
>>> Yes.  In the line "k() < l() &&", the "<" is being recognised as a
>>> template opener.
>>
>> Is it possible to say that "<" can't be a template opener when it
>> comes after a close paren? (I can't think of a case in C++ where that
>> would fail, though I'm not 100% certain there isn't one)
>
> operator()<foo>

So could we say "<" can't be a template opener when it comes after a
close paren except for the close paren of "operator()"?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
  2016-08-18 12:11       ` npostavs
@ 2016-08-22 11:08         ` Alan Mackenzie
  2016-08-25  1:24           ` npostavs
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2016-08-22 11:08 UTC (permalink / raw)
  To: npostavs; +Cc: Arash, Andreas Schwab, 24195

Hello, Noam.

On Thu, Aug 18, 2016 at 08:11:26AM -0400, npostavs@users.sourceforge.net wrote:
> Andreas Schwab <schwab@linux-m68k.org> writes:

> > On Aug 12 2016, Noam Postavsky <npostavs@users.sourceforge.net> wrote:

> >> On Thu, Aug 11, 2016 at 8:14 AM, Alan Mackenzie <acm@muc.de> wrote:
> >>> Yes.  In the line "k() < l() &&", the "<" is being recognised as a
> >>> template opener.

> >> Is it possible to say that "<" can't be a template opener when it
> >> comes after a close paren? (I can't think of a case in C++ where that
> >> would fail, though I'm not 100% certain there isn't one)

> > operator()<foo>

> So could we say "<" can't be a template opener when it comes after a
> close paren except for the close paren of "operator()"?

We could, but I can't see it helping very much (though it might help a
little bit).

There are probably quite a lot of special cases like that where it is
possible to say for sure that the "<" does/doesn't introduce a template
construct.  But that will leave a lot of ambiguous cases.  The more we
try to analyse these, the closer we get to building a compiler inside CC
Mode.  For example, the example given might have been "k < l() && ....",
leaving no syntactic clues about the templateicity of "<".

Analysing the C++ syntax to determine these determinable cases would be
a lot of work, and it would be a lot of work to implement it, too.

The C++ standards people haven't thought it worthwhile to preserve
unambigious syntax in their language, so there is no way CC Mode can get
it right every time.

-- 
Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
  2016-08-22 11:08         ` Alan Mackenzie
@ 2016-08-25  1:24           ` npostavs
  0 siblings, 0 replies; 8+ messages in thread
From: npostavs @ 2016-08-25  1:24 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Arash, Andreas Schwab, 24195

tags 24195 wontfix
quit

Alan Mackenzie <acm@muc.de> writes:

>> So could we say "<" can't be a template opener when it comes after a
>> close paren except for the close paren of "operator()"?
>
> We could, but I can't see it helping very much (though it might help a
> little bit).
>
> There are probably quite a lot of special cases like that where it is
> possible to say for sure that the "<" does/doesn't introduce a template
> construct.  But that will leave a lot of ambiguous cases.  The more we
> try to analyse these, the closer we get to building a compiler inside CC
> Mode.  For example, the example given might have been "k < l() && ....",
> leaving no syntactic clues about the templateicity of "<".
>
> Analysing the C++ syntax to determine these determinable cases would be
> a lot of work, and it would be a lot of work to implement it, too.
>
> The C++ standards people haven't thought it worthwhile to preserve
> unambigious syntax in their language, so there is no way CC Mode can get
> it right every time.

Makes sense, I've been out of C++ for some time, so I kind of forgot how
ridiculous the syntax is.  Marking as wontfix.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-08-25  1:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-10  9:38 bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode) Arash
2016-08-10 22:07 ` Robert Cochran
2016-08-11 12:14 ` Alan Mackenzie
2016-08-12 15:26   ` Noam Postavsky
2016-08-12 16:56     ` Andreas Schwab
2016-08-18 12:11       ` npostavs
2016-08-22 11:08         ` Alan Mackenzie
2016-08-25  1:24           ` npostavs

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).