From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: A question about cycle-spacing--context Date: Sun, 25 Jan 2015 16:38:48 -0800 (PST) Message-ID: <8ef7fe93-f9c7-41ba-b3b4-0dadd3c8190b@default> References: <87twzefnjg.fsf@wmi.amu.edu.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1422232750 11101 80.91.229.3 (26 Jan 2015 00:39:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Jan 2015 00:39:10 +0000 (UTC) To: Marcin Borkowski , Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 26 01:39:10 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YFXht-00066o-KQ for geh-help-gnu-emacs@m.gmane.org; Mon, 26 Jan 2015 01:39:09 +0100 Original-Received: from localhost ([::1]:39427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFXhs-0005ju-Kl for geh-help-gnu-emacs@m.gmane.org; Sun, 25 Jan 2015 19:39:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48660) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFXhg-0005eq-DD for help-gnu-emacs@gnu.org; Sun, 25 Jan 2015 19:38:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFXhc-0003Dd-DN for help-gnu-emacs@gnu.org; Sun, 25 Jan 2015 19:38:56 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:19676) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFXhc-0003DY-6z for help-gnu-emacs@gnu.org; Sun, 25 Jan 2015 19:38:52 -0500 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t0Q0covS001010 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 26 Jan 2015 00:38:51 GMT Original-Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t0Q0clpN002291 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 26 Jan 2015 00:38:49 GMT Original-Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t0Q0clsc006264; Mon, 26 Jan 2015 00:38:47 GMT In-Reply-To: <87twzefnjg.fsf@wmi.amu.edu.pl> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:102270 Archived-At: > Here's what I found in the definition of cycle-spacing: > (cons n (cons orig-pos (buffer-substring start (point)))) > Is there any particular reason for using this instead of just > (list n orig-pos (buffer-substring start (point)))? No, not that I can see. > (Of course, the results are formally different, but functionally > the same, and in the current implementation, thus defined > cycle-spacing--context is not even a "proper", nil-terminated > list!) I understand that the current implementation saves memory > So, my question is: (1) why is that so and (2) would it be a good > practice to employ such an idea in my own code? (I suppose the > answers are (1) why not? and (2) no, but I'd like to ask anyway.) I think you are asking whether and when it makes sense to use dotted lists in your own code. If so, the answer lies in what you use the possibly dotted list for. If you expect to be able to use list operations (e.g. `mapcar') on it then the answer is generally no. If you are using it as a simple, large (many conses) alist, especially one that is created anew often, then the answer might be "Why not?" The answer is to look at how it is being used in your code and judge whether it is convenient or inconvenient etc. FWIW, I probably would not have bothered to use a dotted list in this case. But there is nothing really wrong with doing so. For clarity, I'd say start by using proper lists, and change to a dotted list here or there if you find a good reason to do so. > Also, this is yet another time I see a symbol with two consecutive > dashes. This might be a naive question, but is there any convention > used here that I do not know of? Some of the Emacs developers like to use `--' to indicate an "internal" function, variable or whatever, by which is meant only that its implementation is not guaranteed not to change (which is anyway true of any function, var or whatever!). You can take it as a hint that if you write code that uses such an "internal" thingy then you are on your own if and when an Emacs release changes its use or behavior.