From: Alan Mackenzie <acm@muc.de>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: eliz@gnu.org, emacs-devel@gnu.org, rms@gnu.org, npostavs@gmail.com
Subject: Re: Opaque objects and Emacs documentation
Date: Tue, 21 Jul 2020 19:36:18 +0000 [thread overview]
Message-ID: <20200721193618.GA8562@ACM> (raw)
In-Reply-To: <69716ecb-8984-23e0-8b44-322ea3582384@yandex.ru>
Hello, Dmitry.
On Tue, Jul 21, 2020 at 04:09:18 +0300, Dmitry Gutov wrote:
> On 20.07.2020 05:44, Richard Stallman wrote:
> > [[[ To any NSA and FBI agents reading my email: please consider ]]]
> > [[[ whether defending the US Constitution against all enemies, ]]]
> > [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> > > Consider the docstring of said constructor function. What should it say
> > > its return value is?
> > One natural possibility:
> > Return an empty project object. You need to store values in it with ...
> > Another:
> > Return a project object with name MAME and containing files FILES.
> > I am guessing here. I don't know what these projects do.
> > I don't know what data a project object should have.
> Okay, see, neither option is going to work.
> We have a "factory" function (called 'project-current') which delegates
> project instance creation to a hook. Which is what makes it extensible.
> The only argument is DIRECTORY, meaning the current directory. The
> functions in the hook get called in turn, and the first one that returns
> non-nil is going to be used. Its return value must be a "project
> instance" which satisfies a certain protocol defined by several
> cl-generic methods (think "interface" in Java, or "typeclass" in
> Haskell, or "protocol" in Clojure, or multimethods elsewhere). One
> method is mandatory to be defined for all project implementations, the
> rest have default implementations.
> Thanks to the cl-generic infrastructure, the datatype representing the
> current project can be almost anything, and the structure of the fields
> inside can be arbitrary.
You seem to be writing that as though it were a good thing. From the
perspective of somebody who's likely to want to debug things like this in
the future, it sounds like a Bad Thing indeed. What precisely forces you
to use such difficult and arcane facilities? What does it gain you that
you couldn't get out of plain Emacs Lisp (without things like
cl-generic)?
> This is sorted out by each individual backend which knows how to access
> fields inside "project instances" belonging to it, and which implements
> the aforementioned protocol for that instance type.
Trouble is, when I'm trying to debug a problem involving such code, that
style of coding adds an order of magnitude onto the time and effort
needed.
> The two built-in backends use very simple structures (right now: conses
> like (TYPE-TAG . PROJECT-ROOT)), which is very obvious from their
> implementations. The core of the dispute is whether project-current's
> docstring should document the return value in detail (giving an example
> of built-in project instances's structure). Eli is insisting on it
> because (AFAICT) that suits his thought process and he thinks that will
> help users/clients to make sense of how things work.
if it is not documented in detail, it will add another order of magnitude
onto the time to debug it; anybody needing to know the structure of a
return value in detail, possibly to check it's valid, would first have to
read and understand the intricate details of the source code, and
effectively recreate in her private notes the details missing from the
doc string.
That isn't fun. Not so long ago I gave up on an Edebug bug because the
proliferation of inadequately documented cl- functions in edebug.el just
made it too tedious to continue.
> I am adamantly against this because it's against the design (clients
> should program against the public interface, not against the
> implementation), and is likely to encourage incorrect programs.
That's known as "security by obscurity", I think. I think your fear is
misfounded. For a start, if the public interface is adequate, people
will use it in preference to dissecting internal structures. When gaps
are found in that interface, people will use the internal details to
craft a workaround whether the documentation is there or not. (I have
done this at least once in the past.)
> Of course, we can add this information elsewhere, e.g. in the comments
> of the "backend" functions (which are the elements of the hook I
> mentioned above). I haven't done so because, well, the implementations
> are fairly transparent and the structures are trivial. But I wouldn't
> object against somebody doing that.
I think that is the job of the package's author/maintainer.
> > It is important to document the meaning of each slot -- that may not
> > be obvious. Which values are valid?
> The space of possible structures of valid project instances is
> theoretically infinite.
It remains important to document that infinite space.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2020-07-21 19:36 UTC|newest]
Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200712184908.13140.5739@vcs0.savannah.gnu.org>
[not found] ` <20200712184909.BBC61209B1@vcs0.savannah.gnu.org>
2020-07-12 20:07 ` master 0339325: ; * lisp/progmodes/project.el (project-current): Doc fix Dmitry Gutov
2020-07-13 3:48 ` Eli Zaretskii
2020-07-13 11:09 ` Dmitry Gutov
2020-07-13 13:21 ` Eli Zaretskii
2020-07-13 14:14 ` Dmitry Gutov
2020-07-16 22:40 ` Dmitry Gutov
2020-07-17 6:56 ` Opaque objects and Emacs documentation Eli Zaretskii
2020-07-17 8:13 ` tomas
2020-07-17 10:40 ` Dmitry Gutov
2020-07-17 15:38 ` tomas
2020-07-17 10:37 ` Basil L. Contovounesios
2020-07-17 10:46 ` Dmitry Gutov
2020-07-17 10:53 ` Basil L. Contovounesios
2020-07-17 10:53 ` Dmitry Gutov
2020-07-17 11:14 ` Eli Zaretskii
2020-07-17 12:02 ` Noam Postavsky
2020-07-17 12:52 ` Eli Zaretskii
2020-07-17 13:09 ` Dmitry Gutov
2020-07-17 13:56 ` Eli Zaretskii
2020-07-17 14:35 ` Dmitry Gutov
2020-07-17 14:59 ` Eli Zaretskii
2020-07-17 15:03 ` Dmitry Gutov
2020-07-18 1:54 ` Richard Stallman
2020-07-18 19:17 ` Dmitry Gutov
2020-07-19 2:27 ` Richard Stallman
2020-07-19 14:48 ` Eli Zaretskii
2020-07-21 19:00 ` Dmitry Gutov
2020-07-21 19:36 ` Eli Zaretskii
2020-07-21 20:56 ` Dmitry Gutov
2020-07-21 21:06 ` Tomas Hlavaty
2020-07-21 20:49 ` Tomas Hlavaty
2020-07-21 20:59 ` Dmitry Gutov
2020-07-21 21:20 ` Tomas Hlavaty
2020-07-21 21:25 ` Dmitry Gutov
2020-07-21 19:08 ` Dmitry Gutov
2020-07-21 19:38 ` Eli Zaretskii
2020-07-21 21:02 ` Dmitry Gutov
2020-07-21 20:29 ` John Yates
2020-07-22 0:45 ` Dmitry Gutov
2020-07-22 14:08 ` Eli Zaretskii
2020-07-19 22:02 ` Dmitry Gutov
2020-07-20 2:44 ` Richard Stallman
2020-07-21 1:09 ` Dmitry Gutov
2020-07-21 8:57 ` tomas
2020-07-21 10:14 ` Dmitry Gutov
2020-07-21 10:29 ` tomas
2020-07-21 14:34 ` Eli Zaretskii
2020-07-21 18:56 ` Dmitry Gutov
2020-07-21 19:33 ` Eli Zaretskii
2020-07-21 21:31 ` Dmitry Gutov
2020-07-22 14:28 ` Eli Zaretskii
2020-07-22 15:44 ` Dmitry Gutov
2020-07-22 16:30 ` Eli Zaretskii
2020-07-22 16:37 ` Dmitry Gutov
2020-07-21 19:36 ` Alan Mackenzie [this message]
2020-07-21 21:17 ` Dmitry Gutov
2020-07-21 22:12 ` Edebug (was: Opaque objects and Emacs documentation) Stefan Monnier
2020-07-22 14:31 ` Opaque objects and Emacs documentation Eli Zaretskii
2020-07-22 15:33 ` Dmitry Gutov
2020-07-22 16:22 ` Eli Zaretskii
2020-07-22 16:26 ` Dmitry Gutov
2020-07-23 4:04 ` Richard Stallman
2020-07-23 13:42 ` Dmitry Gutov
2020-07-22 11:43 ` João Távora
2020-07-17 13:08 ` Dmitry Gutov
2020-07-17 13:42 ` Dmitry Gutov
2020-07-17 14:22 ` Eli Zaretskii
2020-07-17 14:56 ` Dmitry Gutov
2020-07-17 16:56 ` John Yates
2020-07-17 17:13 ` Drew Adams
2020-07-17 19:04 ` Eli Zaretskii
2020-07-17 19:26 ` Dmitry Gutov
2020-07-17 19:25 ` Dmitry Gutov
2020-07-17 11:53 ` Gregory Heytings via Emacs development discussions.
2020-07-17 13:13 ` Dmitry Gutov
2020-07-17 14:26 ` Gregory Heytings via Emacs development discussions.
2020-07-17 16:58 ` Drew Adams
2020-07-17 19:22 ` Dmitry Gutov
2020-07-17 22:30 ` Gregory Heytings via Emacs development discussions.
2020-07-18 0:00 ` Yuan Fu
2020-07-18 1:01 ` Drew Adams
2020-07-18 1:55 ` Richard Stallman
2020-07-17 16:48 ` Stefan Monnier
2020-07-23 23:24 ` Andy Moreton
2020-07-23 23:40 ` Andy Moreton
2020-07-24 5:32 ` Eli Zaretskii
2020-07-24 11:23 ` Andy Moreton
2020-07-24 11:43 ` Eli Zaretskii
2020-07-24 0:43 ` Dmitry Gutov
2020-07-24 1:22 ` Andy Moreton
2020-07-24 5:47 ` Eli Zaretskii
2020-07-25 16:33 ` Andy Moreton
2020-07-25 16:51 ` Eli Zaretskii
2020-07-25 20:18 ` Andy Moreton
2020-07-26 2:27 ` Eli Zaretskii
2020-07-26 9:16 ` Andy Moreton
2020-07-26 14:02 ` Eli Zaretskii
2020-07-24 20:49 ` Dmitry Gutov
2020-07-25 16:38 ` Andy Moreton
2020-07-24 5:45 ` Eli Zaretskii
2020-07-24 14:56 ` Dmitry Gutov
2020-07-24 17:21 ` Drew Adams
2020-07-24 17:42 ` Eli Zaretskii
[not found] <<20200712184908.13140.5739@vcs0.savannah.gnu.org>
[not found] ` <<20200712184909.BBC61209B1@vcs0.savannah.gnu.org>
[not found] ` <<7bf4d6ef-c0ec-43dc-ad5d-f6e81422ad90@yandex.ru>
[not found] ` <<83zh84m5ws.fsf@gnu.org>
[not found] ` <<3dd1c224-69b2-40af-5b2e-43a310253632@yandex.ru>
[not found] ` <<83tuybmtxs.fsf@gnu.org>
[not found] ` <<859f594b-1343-6d26-e1ac-7157c44eb56c@yandex.ru>
[not found] ` <<83a6zyk4tt.fsf@gnu.org>
2020-07-17 15:41 ` Drew Adams
2020-07-17 15:49 ` Dmitry Gutov
2020-07-17 15:59 ` Drew Adams
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=20200721193618.GA8562@ACM \
--to=acm@muc.de \
--cc=dgutov@yandex.ru \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=npostavs@gmail.com \
--cc=rms@gnu.org \
/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).