unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Óscar Fuentes" <ofv@wanadoo.es>
To: emacs-devel@gnu.org
Subject: Re: Wierd Elispsisms
Date: Mon, 12 Aug 2013 00:33:45 +0200	[thread overview]
Message-ID: <87eh9zn9h2.fsf@wanadoo.es> (raw)
In-Reply-To: CAAeL0ST3jo_N3B5AJ99LX5D9BeAXaR1zVixNkHzaTgH4Eg_jug@mail.gmail.com

Juanma Barranquero <lekktu@gmail.com> writes:

> On Sun, Aug 11, 2013 at 1:16 PM, Óscar Fuentes <ofv@wanadoo.es> wrote:
>
>> look bizarre. As someone who is not strong on Elisp, I was puzzled at
>> first. Finally realized that the point is to force a boolean value for
>> `compressed'.
>
> Both expressions are common enough.

Grepping for "(not (not " on .el files under lisp/ shows 11 occurrences.
Detecting "(and ... t) is harder, so didn't tried. However, if casting a
value to a boolean is a common task, that's a strong reason for
delegating the job to a function.

>> And, if there exists a reason for using nil/t instead of the original
>> value here and elsewhere, why doesn't exist a function for casting an
>> arbitrary value to a boolean?
>
> Generally speaking, I'd say (not (not X)) or (and X t) can be
> optimized and a funcall not.

I guess that the byte-compiler could apply the same optimization to a
defsubst.

> But anyway, I suspect the answer is, why
> use a function when you have a simple idiom every lisp programmer will
> understand and have quite internalized?  To me, what you're asking is
> as if you objected to the common use of (or x y) instead of (if x x
> y). Idioms.

As already mentioned, they don't look simple to me, but I'm not a Lisp
programmer (neither are most Emacs users who at some point try to hack
some Elisp).

About the idioms, C allows lots of things which are quite "obvious" to
the eyes of the expert C hacker and for a long time writing C code on a
certain "clever" (read "compressed & mind twisting") way was considered
the hallmark of the expert, but nowadays those idioms are often
discouraged, as they make the code hard to read and maintain. We could
say the same about most languages, with some extreme cases (Perl)

All this is IMHO, no big issue, I just was curious. Thanks for
explaining Juanma.




  reply	other threads:[~2013-08-11 22:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1V8JCW-0006AY-BZ@vcs.savannah.gnu.org>
2013-08-11 11:16 ` Wierd Elispsisms (was: trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups.) Óscar Fuentes
2013-08-11 11:41   ` Juanma Barranquero
2013-08-11 22:33     ` Óscar Fuentes [this message]
2013-08-11 18:28 ` trunk r113793: lisp/*.el: More lexical-binding warnings' cleanups Glenn Morris
2013-08-12 15:12   ` Juanma Barranquero

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=87eh9zn9h2.fsf@wanadoo.es \
    --to=ofv@wanadoo.es \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

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