From: Zhu Zihao <all_but_last@163.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Zhu Zihao <all_but_last@163.com>, emacs-devel@gnu.org
Subject: Re: New lisp library -- cell.el
Date: Sat, 29 Feb 2020 00:51:49 +0800 [thread overview]
Message-ID: <875zfqejtm.wl-all_but_last@163.com> (raw)
In-Reply-To: <jwvmu92viik.fsf-monnier+emacs@gnu.org>
> Why not use nil for "none"? That would simplify your code and most
> likely would make for much more natural/idiomatic code in the clients of
> your library.
> [ Traditionally in Lisp when you need something like a "option` (aka
> `Maybe`) type, you use `(cons X nil)` for `some X` and `nil` for `none`. ]
I tend to keep None variant a singleton of cell-option. nil is over-overloaded
in Lisp programming. For example, if we want to store a nullable value in the
slot of cl-struct and we use nil as none. It's hard to differentiate "Slot is
unintialized" and "Slot is initialized with None".
> Why bother with those indirections?
Docstring generated by `cl-defstruct` may not suitable for us. An alias to make
a meaningful doc.
Or should we use (put 'cell-box-inner 'function-documentation ".....")?
> That makes every call to `cell-weak-get` allocate a new symbol only to
> throw it away. I'd recommend you define a top-level constant
Or use '(nil)? map.el use this. But IMO your solution (return nil for GCed weak ref) is better.
next prev parent reply other threads:[~2020-02-28 16:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-28 6:21 New lisp library -- cell.el Zhu Zihao
2020-02-28 8:51 ` Zhu Zihao
2020-02-28 15:43 ` New " Stefan Monnier
2020-02-28 16:51 ` Zhu Zihao [this message]
2020-02-29 3:30 ` Stefan Monnier
2020-02-29 6:48 ` Zhu Zihao
2020-02-29 14:09 ` Stefan Monnier
2020-03-01 7:43 ` Zhu Zihao
2020-03-05 15:52 ` Stefan Monnier
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=875zfqejtm.wl-all_but_last@163.com \
--to=all_but_last@163.com \
--cc=emacs-devel@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.
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.