emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pcase defuns


From: Richard Stallman
Subject: Re: pcase defuns
Date: Mon, 20 Dec 2021 23:15:01 -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 via email to

[Prev in Thread] Current Thread [Next in Thread]