[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: internal data structure
From: |
Emanuel Berg |
Subject: |
Re: internal data structure |
Date: |
Sat, 20 May 2017 16:33:02 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
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