From: "Drew Adams" <drew.adams@oracle.com>
To: kevin.d.rodgers@gmail.com, 8670@debbugs.gnu.org
Subject: bug#8670: OT: bug#8667: 24.0.50; `bounds-of-thing-at-point' returns (N . N) for `comment'
Date: Fri, 13 May 2011 07:24:56 -0700 [thread overview]
Message-ID: <782D11B8AC634A0CBBA9234C66ECF816@us.oracle.com> (raw)
In-Reply-To: <iqih4u$fh4$1@dough.gmane.org>
> > (Dunno why some people insist on using `(if (and...)
> > singleton)'. It gets in the way of readability and just
> > represents extra noise. Binary `if' is generally an
> > impediment to readability and communicating intention.)
>
> Readability is in the eye of the beholder, intention is in
> the mind of the author.
Which is why I said "readability AND communicating intention". And I said
"COMMUNICATING intention", not just "intention". Communicating involves both
the writer and the reader. If the writer's intent is to be communicated well
then readers need to be able to grasp it easily by reading.
> Personally, I think (if (and...) result) communicates the
> intent more clearly than (and ... result)
Really? What's the intent? The result of evaluating
(and A B C D E) is pretty clear: nil or E.
You write that which way? What does adding `if' do for you?
You can add `if' quite a bit, but what does it help?
(and A B C D E)
(if (and A B C D) E) - clearer?
(if (if (and A B C) D) E) - even clearer?
(if (if (if (and A B) C) D) E) - yet clearer?
(if (if (if (if A B) C) D) E) - clearest?
To each his own...
The problem with binary `if' is that it requires more careful parsing, to
distinguish a single sexp from two (2 sexps from 3). It can be pretty easy to
mistake a binary for a ternary `if', or vice versa, depending on the actual
argument sexps.
But if you know that a writer systematically uses:
(a) `when' and `unless' to indicate that the result is
unimportant/unused (only side effects matter),
(b) `if' only as ternary, never binary,
(c) `and' and `or' when args are to be eval'd in order
and the result is significant/used
then it is very quick to follow the code's meaning and author's intent. Coming
across a binary `if' in this context then raises a red flag. Of course, when
debugging a section of code that is problematic you must always double-check
that the writer actually respected the convention, but otherwise it's a breeze.
Is this a widespread convention? Yes and no. Many writers of Common Lisp
follow it; some (many?) do not. It helps when you pretty much know that the
writer follows it (e.g. when I read my own code). All bets are off if no
convention is followed wrt these functions.
Personally, I consider use of `if' when the result is not important, and use of
`when' or `unless' when the result matters, to be perverse. The other parts of
the convention are less important/useful, to me.
If you want to super-if-ify the Emacs source code, as above, feel free. Reduce
all uses of `and' to binary `and' if you want, or eliminate use of `and'
altogether.
next prev parent reply other threads:[~2011-05-13 14:24 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-13 0:46 bug#8667: 24.0.50; `bounds-of-thing-at-point' returns (N . N) for `comment' Drew Adams
2011-05-13 3:00 ` Drew Adams
2011-05-13 5:56 ` Kevin Rodgers
2011-05-13 14:24 ` Drew Adams [this message]
2011-05-13 14:11 ` Stefan Monnier
2011-05-13 15:49 ` Drew Adams
2011-05-13 16:11 ` Drew Adams
2011-05-13 17:05 ` Stefan Monnier
2011-05-19 17:12 ` Drew Adams
2011-05-20 2:12 ` Stefan Monnier
2011-05-21 14:52 ` Drew Adams
2011-05-21 15:06 ` Eli Zaretskii
2011-05-21 15:15 ` Drew Adams
2011-05-21 15:52 ` Eli Zaretskii
2011-05-21 18:18 ` Drew Adams
2011-05-27 14:08 ` Drew Adams
2011-05-27 14:11 ` HTTP access to Emacs source code Drew Adams
2011-05-27 18:11 ` Eli Zaretskii
2011-05-27 18:19 ` Drew Adams
2011-05-27 20:51 ` Drew Adams
2011-05-27 21:17 ` Eli Zaretskii
2011-05-27 21:58 ` Drew Adams
2011-05-27 23:01 ` Christoph Scholtes
2011-05-27 23:05 ` Drew Adams
2011-05-27 23:40 ` Paul Eggert
2011-05-28 0:51 ` Stefan Monnier
2011-05-28 1:11 ` Glenn Morris
2011-05-28 7:13 ` Eli Zaretskii
2011-05-19 18:24 ` bug#8667: 24.0.50; `bounds-of-thing-at-point' returns (N . N) for `comment' Drew Adams
2011-05-20 2:18 ` Stefan Monnier
2011-05-21 14:51 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=782D11B8AC634A0CBBA9234C66ECF816@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=8670@debbugs.gnu.org \
--cc=kevin.d.rodgers@gmail.com \
/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.