unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: "'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'"
	<help-gnu-emacs@gnu.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: FW: FW: [External] : Re: Lisp anime video
Date: Sat, 4 Sep 2021 19:16:27 +0000	[thread overview]
Message-ID: <SJ0PR10MB548871134AC319C470CD9340F3D09@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: jwv7dfwgvb9.fsf-monnier+emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2476 bytes --]

> > Any pronunciation you like is fine, but it
> > really should differentiate things like
> > cddr and caddr and cadar.  IOW, in particular
> > it needs to distinguish things like cdr and
> > cdar.
> 
> In my book, the pronounciation of those cXXXr is the least of
> their problems.  They make the code hard to understand anyway.
> I strongly recommend limiting oneself to cXr and cXXr, and preferring
> `nth` and `nthcdr` or defining new types with `cl-defstruct` so you can
> use proper names for the relevant fields.
> 
> cXXXr is Lisp's equivalent to writing assembly code IMO (tho without
> the speed benefit).

Yes.  (And but/no...)

Certainly, code that goes much beyond just car
and cdr, and even some code that uses car & cdr,
can typically benefit from instead using names
specific to the data or its current use.

For local naming, `let'.  For general naming,
e.g., for a global, complex structure, either
something like `defstruct' (named fields/slots)
or Lisp macros for accessing the various parts.
IOW, use names that are _meaningful for the
given context_.
___

OTOH, cXXXr patterns are just that: patterns.
With some getting used to, it's not so hard to
view their use that way.  That can (and does)
happen naturally/unconsciously.

Certainly seeing the simplest ones, such as cadr,
over and over and over makes their meaning/use
somewhat second nature.

I'm sure you don't think twice when you see cadr.
You just think "second"; you don't visualize
taking the cdr and then taking the car of that
result.  You "see" the cadr.  Your mental
processing is declarative and direct at that
point, not procedural.  Maybe the same for caddr
("third") or cadddr ("fourth").

After a while, seeing cXXXr can be essentially
the same as "seeing through" parentheses - same
idea/reflex.  Just as you can see (this bit)
within (x y z (this bit)), so you can see it as
the cadddr.

[The cons is (x . (y . (z . ((this bit) . nil)))).]

Neither "seeing through" parens nor reading
cXXXr directly are obvious, but being able to
do one is about the same as being able to do
the other, I think.

It's like driving a car or riding a bike or
playing an instrument naturally.  You don't
think, "Turn on the blinker, turn the wheel
to the left,..." - you just do it.
___

(Again, to be clear, I do _not_ advocate using
cXXXr in general - better to use helpful,
context-relevant names for specific bits of
data.)

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14642 bytes --]

  parent reply	other threads:[~2021-09-04 19:16 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-29  5:28 Lisp anime video Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-29  5:30 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-29  5:43 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-29  7:40 ` tomas
2021-08-29  8:11   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-29 10:00     ` tomas
2021-08-29 10:57       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-29 12:06         ` tomas
2021-08-29 15:44           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-29 16:04             ` tomas
2021-08-29 16:10               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-29 11:01     ` Philip Kaludercic
2021-08-29 17:42       ` [External] : " Drew Adams
2021-08-29 17:44         ` Drew Adams
2021-08-30 22:59           ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-31  2:14             ` Drew Adams
2021-09-04 10:45             ` Wayne Harris via Users list for the GNU Emacs text editor
2021-08-29 18:03         ` Philip Kaludercic
2021-08-29 18:05           ` Drew Adams
2021-08-30  0:19         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-30 11:57           ` Marcin Borkowski
2021-08-30 15:13             ` Colin Baxter
2021-08-29 17:42       ` Drew Adams
2021-09-04 10:49       ` Wayne Harris via Users list for the GNU Emacs text editor
2021-09-04 13:44         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-04 15:12           ` Wayne Harris via Users list for the GNU Emacs text editor
2021-09-04 22:55             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-05  0:13               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-05  1:20                 ` [External] : " Drew Adams
2021-09-05  1:27                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-05 15:14                     ` Drew Adams
2021-09-05 15:16                       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-05  7:29                 ` tomas
2021-09-05 14:46                   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-05 15:05                     ` tomas
2021-09-05 15:11                       ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-05 19:55                       ` Arthur Miller
2021-09-05 21:02                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-06  5:08                           ` Arthur Miller
2021-09-04 15:39           ` FW: [External] : " Drew Adams
2021-09-04 16:31             ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-09-04 17:51               ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-04 19:16               ` Drew Adams [this message]
2021-09-24  5:38             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-24  6:53               ` tomas
2021-09-24  7:30                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-24 16:39                   ` Drew Adams
2021-09-24 17:03                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-24 18:44                       ` Drew Adams
2021-08-29  8:14   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-08-29  8:25     ` Omar Polo
2021-09-04 10:52       ` Wayne Harris via Users list for the GNU Emacs text editor
2021-08-29 10:03     ` tomas
2021-08-29 15:07     ` Arthur Miller

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=SJ0PR10MB548871134AC319C470CD9340F3D09@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@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.
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).