unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: internal data structure
Date: Sat, 20 May 2017 16:33:02 +0200	[thread overview]
Message-ID: <yw.86k25blhsx.fsf@zoho.com> (raw)
In-Reply-To: CALeZmBuo9VxG9nPBhdfBhix5N6msMbQ9WTJ0=2gyDZ4bxsVcZQ@mail.gmail.com

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




      parent reply	other threads:[~2017-05-20 14:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 12:54 internal data structure Alexander Doe
2017-05-20 14:27 ` tomas
2017-05-20 14:33 ` Emanuel Berg [this message]

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=yw.86k25blhsx.fsf@zoho.com \
    --to=moasen@zoho.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).