From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Circular Lists that are not lists?
Date: Sun, 15 Sep 2013 08:43:42 +0200 [thread overview]
Message-ID: <877geitwip.fsf@gmail.com> (raw)
In-Reply-To: 874n9na3j1.fsf@informatimago.com
"Pascal J. Bourguignon" <pjb@informatimago.com> writes:
Hi,
> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> Hi List,
>>
>> in a parse-tree produced calling 'org-element-parse-buffer' in
>> org-buffer "tmp.org" I see that the first first-level headline is tagged
>> with a :CATEGORY attribute:
>>
>> ,---------------------------------------
>> | (headline (:CATEGORY #1=\"tmp\" ...))
>> `---------------------------------------
>>
>> and that the other headlines in the parse-tree reference the attribute
>> value:
>>
>> ,-------------------------------
>> | (headline (:CATEGORY #1# ...))
>> `-------------------------------
>>
>> except when a category is explicitly specified for them:
>>
>> ,------------------------------------------------
>> | (headline (:CATEGORY \"My Category Name\" ...))
>> `------------------------------------------------
>>
>> Now ignore the Org-mode specific stuff, this question is really about
>> circular lists.
>>
>> This seems to be a case where circular lists are applied to strings -
>> should they rather be called circular sequences?
>>
>> How can I distinguish the three cases shown when mapping the parse-tree,
>> i.e. not on the textual level after printing the tree with (print-circle
>> t), but while mapping the nested list?
>>
>> - case 1 :: value defined #1=\"tmp\"
>>
>> - case 2 :: value referenced #1#
>>
>> - case 3 :: custom value without circular characteristics
>>
>> ?
>>
>> When getting the property's values, they are all just strings ...
>
> #= and ## are just a way to refer to the same object when reading a
> sexp.
>
> This has nothing to do with circular lists, or circular structures,
> other than they're the only way to build such circular lists or circular
> structures at read time.
>
> But references can be used without anything circular.
>
> (defvar *knights-saying* '(#1=Ni! #1# #1#))
> *knights-saying* ; --> (Ni! Ni! Ni!)
>
> They can also be used without any list:
>
> (defvar *recursive-vector* '#1=[a #1# vector])
> (let ((print-level 4)
> (print-circle nil))
> (print *recursive-vector*))
> ;; in any sane lisp system should print:
> [a [a [a [a # vector] vector] vector] vector]
> ;; but in emacs it doesn't
> ; -> #1=[a #1# vector]
>
> And notice how there can't be any notion of circular vector! But the
> structure built by this vector is "circular" meaning that walking it
> leads to a circle in the graph of objects and references.
>
> I won't give an example with defstruct since in emacs structures are
> actually vector, so we're reduced to the previous case. But you may try
> it as an exercise, both in emacs lisp and in Common Lisp.
>
> Use:
> (setf *print-length* 10 *print-level* 4 *print-circle* nil)
> in Common Lisp.
>
> Circular lists are lists, in the sense that: (deftype list () '(or
> cons null))
Quite a lot of very interesting stuff to digest. Since this
'object-reference' syntax is presented as circular-list read-syntax in
the manual, I thought it was tightly bound to the concept of circular
lists (as the function `print-circle' suggests too), so I was surprised
to see it used with string objects.
Thanks for info (Pascal and Teemu).
--
cheers,
Thorsten
next prev parent reply other threads:[~2013-09-15 6:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.2134.1379166560.10748.help-gnu-emacs@gnu.org>
2013-09-14 14:20 ` Circular Lists that are not lists? Pascal J. Bourguignon
2013-09-15 6:43 ` Thorsten Jolitz [this message]
2013-09-14 13:48 Thorsten Jolitz
2013-09-14 14:05 ` Teemu Likonen
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=877geitwip.fsf@gmail.com \
--to=tjolitz@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/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).