all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Richard Stallman <rms@gnu.org>
To: Andrew Hyatt <ahyatt@gmail.com>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: pcase defuns
Date: Mon, 20 Dec 2021 23:15:01 -0500	[thread overview]
Message-ID: <E1mzWYH-0000dL-GI@fencepost.gnu.org> (raw)
In-Reply-To: <m2tuf48fqz.fsf@andrews-mbp.lan> (message from Andrew Hyatt on Sun, 19 Dec 2021 16:08:20 -0500)

[[[ 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. ]]]

The idea of defining a function in pieces, scattered around one or
more files, is attractive as regards writing them.  But it creates
an inconvenience for subsequent maintenance by other people.

The first thing you're likely to do when you see a call to a function
you don't know about is to find its definition.  For a
piecewise-defined function, "the" definition doesn't exist.  It has a
number of partial definitions, scattered around one file or perhaps
multiple files.

If you think it is helpful for clarity to put the code for handling
various cases in various places in the file, no new construct is
needed for that.  You can define a function for handling each case, and
put its definition in the place you want it.  Then define one overall
function (you can think of it as "generic") which detects the cases
and calls those.

This works with our tools.

Let's contrast this with generic functions.

A generic function has a single central definition
which describes how to call it.  It is easy to find that.

Finding the definitions of all the methods may be difficult.
You may need to grep for them.

Calling the generic function selects a method by data types, and you
can generally tell, for given arguments, what data types they have.
You can probably tell that one method is the right one without seeing
all the others and comparing them.

Thus, generic functions cause one kind of inconvenience for studying a
program, but avoids the other kinds.

Let's not add any constructs that increase the level of complexity of
genericness beyond this.


-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





  reply	other threads:[~2021-12-21  4:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-19  4:53 pcase defuns Andrew Hyatt
2021-12-19  8:34 ` Tassilo Horn
2021-12-19 15:33   ` Andrew Hyatt
2021-12-19 17:16     ` Tassilo Horn
2021-12-19 19:05       ` Stefan Monnier
2021-12-20  5:56         ` Tassilo Horn
2021-12-22 14:07   ` LdBeth
2021-12-19 17:23 ` Stefan Monnier
2021-12-19 21:08   ` Andrew Hyatt
2021-12-21  4:15     ` Richard Stallman [this message]
2021-12-21  5:20       ` Andrew Hyatt
2021-12-22  4:18         ` Richard Stallman
2021-12-23  1:52           ` Andrew Hyatt
2021-12-24  4:13             ` Richard Stallman
2021-12-21 15:32     ` Stefan Monnier
2021-12-20  4:43 ` Richard Stallman
2021-12-23  2:30 ` Po Lu
2022-03-26 17:41 ` Andrew Hyatt
2022-03-27  9:31   ` Stefan Monnier
2022-03-27 18:17     ` Andrew Hyatt
2022-03-28  4:15   ` Richard Stallman
2022-03-30  1:28     ` Andrew Hyatt
2022-03-31  4:27       ` Richard Stallman
2022-04-17 22:09         ` Andrew Hyatt
2022-04-19  3:48           ` Richard Stallman

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1mzWYH-0000dL-GI@fencepost.gnu.org \
    --to=rms@gnu.org \
    --cc=ahyatt@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.