* internal data structure
@ 2017-05-20 12:54 Alexander Doe
2017-05-20 14:27 ` tomas
2017-05-20 14:33 ` Emanuel Berg
0 siblings, 2 replies; 3+ messages in thread
From: Alexander Doe @ 2017-05-20 12:54 UTC (permalink / raw)
To: help-gnu-emacs
Good day Ladies and Gentleman,
which data structure is used by GNU/Emacs for storing and editing text
strings on low-level? List, balanced tree, gap buffer, something else?
Which language is used for programming this? C or ELisp?
with the best regards
Alexander Sidorov
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: internal data structure
2017-05-20 12:54 internal data structure Alexander Doe
@ 2017-05-20 14:27 ` tomas
2017-05-20 14:33 ` Emanuel Berg
1 sibling, 0 replies; 3+ messages in thread
From: tomas @ 2017-05-20 14:27 UTC (permalink / raw)
To: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sat, May 20, 2017 at 02:54:23PM +0200, Alexander Doe wrote:
> Good day Ladies and Gentleman,
>
>
> which data structure is used by GNU/Emacs for storing and editing text
> strings on low-level? List, balanced tree, gap buffer, something else?
It's a gap buffer.
> Which language is used for programming this? C or ELisp?
The machinery is C, but there are some Lisp introspection functions:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-Gap.html
If you have a source installation, then C-h f "describe function" on e.g.
"gap-position" will take you all the way to the C source (somewhere in
editfns.c).
Here's a link to an online resource, for your browsing convenience:
https://git.savannah.gnu.org/cgit/emacs.git/tree/src/editfns.c?h=emacs-25#n1090
Cheers
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlkgUl4ACgkQBcgs9XrR2kY0IgCfV1ZksYeRDlZxkMbFaAlUrI7W
U5YAnjb/b7rBzaJIiXHa7NvI8C5GhVFz
=c3TR
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: internal data structure
2017-05-20 12:54 internal data structure Alexander Doe
2017-05-20 14:27 ` tomas
@ 2017-05-20 14:33 ` Emanuel Berg
1 sibling, 0 replies; 3+ messages in thread
From: Emanuel Berg @ 2017-05-20 14:33 UTC (permalink / raw)
To: help-gnu-emacs
Alexander Doe wrote:
> which data structure is used by GNU/Emacs for
> storing and editing text strings on
> low-level? List, balanced tree, gap buffer,
> something else?
>
> Which language is used for programming this?
> C or ELisp?
Emacs is Lisp on top of C.
The strings in Lisp are data objects that are
string-typed. This contrary to a language like
C where it is the *variable*, non the data
object, that is associated with a type.
That said, there isn't a string type in C.
In C what you do is either you have an array of
chars, or you have a pointer to a char and then
continue in memory a certain number of bytes,
which is the length of the text string, as
1 char is stored as 1 byte.
In practice, the array and pointer methods in
C amount to virtually the same.
By the way, "char" is pronounced "kar"!
In Lisp, or Elisp at least, because everything
is lists, it is tempting to think of a string
as a list of chars, just like the C array.
But technically, this is not the case:
(stringp "Sail Ho!") ; t
(listp "True sailing is dead.") ; nil
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-20 14:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-20 12:54 internal data structure Alexander Doe
2017-05-20 14:27 ` tomas
2017-05-20 14:33 ` Emanuel Berg
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).