From: Vladimir Panteleev <vladimir@thecybershadow.net>
To: Alan Mackenzie <acm@muc.de>
Cc: 18158@debbugs.gnu.org, stefan@marxist.se, russel@winder.org.uk,
liranz@gmail.com
Subject: bug#18158: D Mode: Getting rid of the ugly advice on looking-at.
Date: Thu, 13 Feb 2020 13:37:19 +0000 [thread overview]
Message-ID: <CAHhfkvysqydAm6ZbWtuFt_ruvToqbM8yUx=qaoMoYHtAcKe6fA@mail.gmail.com> (raw)
In-Reply-To: <20200207213100.GB8591@ACM>
Hi Alan,
On Fri, 7 Feb 2020 at 21:31, Alan Mackenzie <acm@muc.de> wrote:> >
Unfortunately, the only way I found to achieve these improvements in D
> Could you possibly give me one or two examples of why these pieces of
> advice are needed? This would give me more of a feel for what the
> problems are.
Yes, gladly.
d-mode installs advice in seven^Wsix places, all of which are in
cc-mode. Here is a rough / brief description of each.
1. The looking-at call from within c-add-stmt-syntax which started
this discussion.
It has been later extended in
075c3e7b8da8bfffe1bbe00cf705494755959fd1 to also apply to "version"
and "debug" blocks.
2. A replacement of c-forward-decl-or-cast-1.
The D version, which is an edited copy of the cc-mode function, has
additional code required to recognize and fontify variable
declarations in foreach statements and lambda expressions, as well as
conditional compilation. The D version (d-forward-decl-or-cast-1)
completely replaces c-forward-decl-or-cast-1, and only a small part of
the original remains.
3. A replacement of c-get-fontification-context.
This one is also used for foreach loops and lambda parameter lists.
I'm not sure the "integration" with cc-mode is that great here - the
code might be using some constants with different conventions than
cc-mode.
4. A replacement of c-in-knr-argdecl.
Here d-mode abuses cc-mode's logic for two features that are
syntactically a bit similar to K&R C argument lists - function
contracts and template constraints. They also exist between the
function signature and its body, so making use of the existing K&R
mechanics in cc-mode seemed like the simplest way to fix support for
these constructs.
5. A replacement of c-forward-type.
This one also implements only exactly the syntax in the D
programming language.
6. A modified version of c-update-brace-stack.
The modifications were necessary to help cc-mode understand static
compilation constructs in the D language. Syntax such as "static if"
does not change whether its substatements are "top-level" or not, and
it can be used with or without a { } pair, which required custom
logic.
As I was making this list, I couldn't remember what one of the advice
was for, so I removed it - and the test suite still passed, so it
seems like my newer changes made it obsolete. I committed the removal.
> How does D compare with C++ in terms of complexity?
I would say D is definitely less complicated than C++, and it's
especially easier to parse (it was designed from the beginning to
avoid pitfalls such as the ambiguity of "a < b, c > d"). However, it
also has many features (for instance, depending on how you count, it
has about seven kinds of string literals). Some troublesome aspects I
ran into while working on d-mode were type inference (types may
sometimes be omitted from declarations) and parameter lists ("(a, b,
c)" is a list of types for a function declaration, like in C, but a
parameter name list with inferred types for lambdas).
> One practical step for option 1 would be for you to have write access to
> the CC Mode repository, in particular to a "D Mode" branch, where you
> could implement the necessary CC Mode features to support D Mode.
> Something like this was done ~10 years ago for enhancing Java Mode.
That would work; though, I might need a bit of guidance with making my
cc-mode modifications acceptable :) E.g., what would be a good way for
derived modes to replace cc-mode functions such as c-forward-type.
> But perhaps a D Mode support file could be included in CC Mode, somewhat
> along the lines of how cc-awk.el supports AWK, but including only
> essential support for D Mode rather than including D Mode itself. I'm
> not sure if I've explained that very well.
I think I understand. Probably it will be clearer which way is best
once we attempt to do so.
> > I would love to hear your thoughts on the above.
>
> I hope I've given you enought to think about. ;-)
Indeed. Thank you for the extensive reply. I agree with and have no
further comments on everything you said not quoted above.
> To reproduce it, I temporarily removed the advice on `looking-at' from D
> Mode. The problem was then apparent in the test code supplied by Liran
> Zvibel on 28th January to me, Cc: to the Emacs bug list.
Oh, I see. Thank you for the clarification. I guess I could have put
two and two together :)
Best regards.
prev parent reply other threads:[~2020-02-13 13:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-31 15:33 bug#18158: Fix extra indent of d-mode "else static if" statements in cc-engine.el Liran Zvibel
2020-01-20 21:18 ` Stefan Kangas
2020-01-26 15:29 ` Alan Mackenzie
2020-01-29 1:26 ` Liran Zvibel
2020-01-31 19:41 ` Alan Mackenzie
2020-02-02 11:56 ` bug#18158: D Mode: Getting rid of the ugly advice on looking-at Alan Mackenzie
2020-02-02 16:59 ` Vladimir Panteleev
2020-02-07 21:31 ` Alan Mackenzie
[not found] ` <20200207213100.GB8591@ACM>
2020-02-13 13:37 ` Vladimir Panteleev [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHhfkvysqydAm6ZbWtuFt_ruvToqbM8yUx=qaoMoYHtAcKe6fA@mail.gmail.com' \
--to=vladimir@thecybershadow.net \
--cc=18158@debbugs.gnu.org \
--cc=acm@muc.de \
--cc=liranz@gmail.com \
--cc=russel@winder.org.uk \
--cc=stefan@marxist.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).