[Top][All Lists]

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

FW: FW: [External] : Re: Lisp anime video

From: Drew Adams
Subject: FW: FW: [External] : Re: Lisp anime video
Date: Sat, 4 Sep 2021 19:16:27 +0000

> > 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

<<attachment: winmail.dat>>

reply via email to

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