From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Zhu Zihao Newsgroups: gmane.emacs.devel Subject: Re: New lisp library -- cell.el Date: Sat, 29 Feb 2020 00:51:49 +0800 Message-ID: <875zfqejtm.wl-all_but_last@163.com> References: Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="113492"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/27.0 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Cc: Zhu Zihao , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 28 18:33:10 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j7jVe-000TR3-IE for ged-emacs-devel@m.gmane-mx.org; Fri, 28 Feb 2020 18:33:10 +0100 Original-Received: from localhost ([::1]:51462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7jVd-0006bV-IB for ged-emacs-devel@m.gmane-mx.org; Fri, 28 Feb 2020 12:33:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33701) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7j7i-0007cL-DU for emacs-devel@gnu.org; Fri, 28 Feb 2020 12:08:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7j7c-0001lQ-KQ for emacs-devel@gnu.org; Fri, 28 Feb 2020 12:08:21 -0500 Original-Received: from m12-18.163.com ([220.181.12.18]:56716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7j7Y-0001iF-LG for emacs-devel@gnu.org; Fri, 28 Feb 2020 12:08:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:Message-ID:From:Subject:MIME-Version; bh=cNL+1 TC/7RC3PsS0KTNz6wNgk8LAxqp46+5c8djLzv4=; b=cczWJmbKG3ovspwBtR+VM gTbHf+hI5SSil1ChanHwUf9/MY8/N4WDZ8qtz+/o53hVaquIRy2TeF0+lldfgkBq a29zsspo9N5YSAAoLoz7RQ40Y56kvoqvdA/qIOzYstXDItmRiKexXDGYDWvS6JJ1 PKQeVTNcARvVL+1mcgS5dI= Original-Received: from archlinux.163.com (unknown [183.19.167.101]) by smtp14 (Coremail) with SMTP id EsCowAAnNo0zRVleTuzXWg--.11961S2; Sat, 29 Feb 2020 00:52:10 +0800 (CST) In-Reply-To: X-Face: :]]%@R1{oDt0%iKgI@Kga#OZ; ogt+%OOne&J4#E*O,TIlI)yEFw--I\:3s~EV97GI$1.1!}8inmF9UgtUBB@#8>'8NWNC8qg/v*OLfQB; Z:@G3HeNf3u& ,&HpBGv%?p{bzsl'|5T";1&X X-CM-TRANSID: EsCowAAnNo0zRVleTuzXWg--.11961S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtFy5uw4rAF4Uuw45Zry5Jwb_yoWDCrX_A3 s5Wr97X34j9w4Iqa1aqFZxtFZrKw40v348WrWkJrs5Krn8A3W5CrWkCrZxGr1Iqw4YvFnx uwsxuF4Sv347GjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRAKsU5UUUUU== X-Originating-IP: [183.19.167.101] X-CM-SenderInfo: pdoosuxxwbztlvw6il2tof0z/xtbBZhrXr1aD5b-YawAAs4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.18 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:245107 Archived-At: > 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.