From: Drew Adams <drew.adams@oracle.com>
To: Marcin Borkowski <mbork@wmi.amu.edu.pl>,
Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: RE: A question about cycle-spacing--context
Date: Sun, 25 Jan 2015 16:38:48 -0800 (PST) [thread overview]
Message-ID: <8ef7fe93-f9c7-41ba-b3b4-0dadd3c8190b@default> (raw)
In-Reply-To: <87twzefnjg.fsf@wmi.amu.edu.pl>
> 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.
next prev parent reply other threads:[~2015-01-26 0:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-25 23:28 A question about cycle-spacing--context Marcin Borkowski
2015-01-26 0:38 ` Drew Adams [this message]
2015-01-26 1:48 ` Artur Malabarba
2015-01-26 3:10 ` Drew Adams
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=8ef7fe93-f9c7-41ba-b3b4-0dadd3c8190b@default \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=mbork@wmi.amu.edu.pl \
/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).