unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Michael Heerdegen <michael_heerdegen@web.de>,
	"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : Closures - do you understand them well?
Date: Thu, 8 Dec 2022 19:35:39 +0000	[thread overview]
Message-ID: <SJ0PR10MB54884F270A08F6111F22AE55F31D9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87mt7xpw7j.fsf@web.de>

> When the reader encounters "()" I expect it to construct an empty list.
> That's what I want, so I quote it to get exactly that when that
> expression is evaluated.
> 
> If we do not limit ourselves to Emacs Lisp, the (not trivial) question
> would else be: what is the return value when evaluating an empty list?
> Not trivial because there can be Lisps where an empty list and a boolean
> "false" are different (AFAIR such Lisps exist).

Scheme.

As CLTL2 says at the outset:

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node9.html#SECTION00522000000000000000

 In Common Lisp, as in most Lisp dialects, the symbol
                 ^^^^^^^^^^^^^^^^^^^^^^^^
 nil is used to represent both the empty list and the
 ``false'' value for Boolean tests.  An empty list may,
 of course, also be written (); this normally denotes
 the same object as nil.... These two notations may be
 used interchangeably as far as the Lisp system is
 concerned.  However, as a matter of style, this book
 uses the notation () when it is desirable to emphasize
 the use of an empty list, and uses the notation nil
 when it is desirable to emphasize the use of the
 Boolean ``false''.  The notation 'nil (note the
 explicit quotation mark) is used to emphasize the use
 of a symbol.  For example:

 (defun three () 3)      ;Emphasize empty parameter list 

 (append '() '()) => ()  ;Emphasize use of empty lists 

 (not nil) => t          ;Emphasize use as Boolean ``false'' 

 (get 'nil 'color)       ;Emphasize use as a symbol

 Any data object other than nil is construed to be Boolean
 ``not false'', that is, ``true''.  The symbol t is
 conventionally used to mean ``true'' when no other value
 is more appropriate.  When a function is said to ``return
 false'' or to ``be false'' in some circumstance, this
 means that it returns nil.  However, when a function is
 said to ``return true'' or to ``be true'' in some
 circumstance, this means that it returns some value other
 than nil, but not necessarily t.

(Note that the second example does what you do.
(Of course at this point in the book there's
been no mention of t and nil/() being
self-evaluating.)

https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node57.html#SECTION00911000000000000000

> Because I don't want to tangent this question I prefer
> to quote the empty list.  What are your reasons to
> prefer to evaluate it and use the result?

No reason not to do that, i.e., no reason to quote it.  

Why not emphasize and take advantage of the fact that 
(always) '() = ()?  No more reason to quote it than
there is (in Elisp, unlike in Common Lisp) to quote a
lambda expression (not speaking about #' "quoting" here).



  reply	other threads:[~2022-12-08 19:35 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08 15:36 Closures - do you understand them well? Michael Heerdegen
2022-12-08 16:24 ` [External] : " Drew Adams
2022-12-08 17:30   ` Michael Heerdegen
2022-12-08 17:56     ` Drew Adams
2022-12-08 18:00       ` Drew Adams
2022-12-08 18:49       ` Michael Heerdegen
2022-12-08 19:35         ` Drew Adams [this message]
2022-12-10  4:51           ` Emanuel Berg
2022-12-08 19:45         ` Drew Adams
2022-12-08 19:06 ` Tassilo Horn
2022-12-08 19:53   ` Michael Heerdegen
2022-12-08 20:01     ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-08 20:49       ` Michael Heerdegen
2022-12-08 22:00         ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-08 22:25           ` [External] : " Drew Adams
2022-12-08 22:51             ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-10  2:34               ` Emanuel Berg
2022-12-09  5:03             ` Tomas Hlavaty
2022-12-10  2:35               ` Emanuel Berg
2022-12-10  2:29             ` Emanuel Berg
2022-12-10 16:56               ` Drew Adams
2022-12-15  8:25                 ` Emanuel Berg
2022-12-09  4:49           ` tomas
2022-12-09 19:40             ` Michael Heerdegen
2022-12-09 19:50               ` tomas
2022-12-09 20:55               ` Tassilo Horn
2022-12-09 21:21                 ` Michael Heerdegen
2022-12-09 21:31                   ` Emanuel Berg
2022-12-09 21:23                 ` Emanuel Berg
2022-12-10 11:40                   ` tomas
2022-12-12  1:18                     ` Michael Heerdegen
2022-12-12  5:16                       ` tomas
2022-12-12  6:09                         ` Michael Heerdegen
2023-01-18 12:13                           ` Emanuel Berg
2023-01-19 13:21                             ` Michael Heerdegen
2023-01-27 20:24                               ` Emanuel Berg
2023-01-28  0:44                                 ` Michael Heerdegen
2023-02-26 12:45                                   ` Emanuel Berg
2023-02-27  8:33                                     ` tomas
2023-02-28 10:13                                     ` Michael Heerdegen
2023-03-01 20:42                                       ` Emanuel Berg
2023-03-03 12:09                                         ` Michael Heerdegen
2023-03-02 11:08                                       ` Michael Heerdegen
2023-03-02 18:25                                         ` Emanuel Berg
2023-03-02 20:48                                           ` Emanuel Berg
2023-03-03  6:56                                             ` Eli Zaretskii
2023-03-03 12:19                                             ` Michael Heerdegen
2023-03-02 18:37                                         ` Emanuel Berg
2023-03-02 18:50                                         ` Emanuel Berg
2023-01-18 12:11                         ` Emanuel Berg
2022-12-22  4:00                     ` Emanuel Berg
2022-12-23  6:27                       ` tomas
2023-01-18 12:23                         ` Emanuel Berg
2022-12-10  4:46                 ` Emanuel Berg
2022-12-10  0:12               ` Michael Heerdegen
2022-12-10  9:34                 ` Tassilo Horn
2022-12-10 10:02                   ` Emanuel Berg
2022-12-10 16:28                   ` Mutation - do you understand it really? (was: Closures - do you understand them well?) Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-10 18:29                     ` Mutation - do you understand it really? Michael Heerdegen
2023-01-18 10:58                       ` Emanuel Berg
2023-01-19 13:59                         ` Michael Heerdegen
2023-01-19 17:47                           ` [External] : " Drew Adams
2022-12-11  2:24                   ` Closures - do you understand them well? Michael Heerdegen
2022-12-11  9:13                     ` Tassilo Horn
2022-12-10  2:26           ` Emanuel Berg
2022-12-10 17:20             ` [External] : " Drew Adams
2022-12-10 18:02               ` Iteration macros (was: [External] : Re: Closures - do you understand them well?) Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-10 20:38                 ` Drew Adams
2023-01-18 11:10                   ` Emanuel Berg
2023-01-18 11:08                 ` Emanuel Berg
2022-12-21 23:53               ` [External] : Re: Closures - do you understand them well? Emanuel Berg
2022-12-09  3:43         ` Emanuel Berg
2022-12-09  4:01           ` Michael Heerdegen
2022-12-09  4:38             ` tomas
2022-12-09  5:37               ` Emanuel Berg
2022-12-09 16:55                 ` Michael Heerdegen
2022-12-10  4:52             ` Emanuel Berg
2022-12-08 19:44 ` Eric Abrahamsen
2022-12-08 20:11   ` Emanuel Berg
2022-12-08 20:53   ` Michael Heerdegen
2022-12-08 23:25     ` Michael Heerdegen
2022-12-09 16:50       ` Eric Abrahamsen
2022-12-09 18:48         ` Emanuel Berg
2022-12-09 19:25         ` Michael Heerdegen
2022-12-11 18:42           ` Eric Abrahamsen
2023-01-18 12:08             ` Emanuel Berg

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=SJ0PR10MB54884F270A08F6111F22AE55F31D9@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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).