emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about Qnil representation


From: Po Lu
Subject: Re: question about Qnil representation
Date: Thu, 27 Oct 2022 08:45:32 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

Troy Hinckley <troyhinckley@gmail.com> writes:

> Sure, but it reinterprets the integer as a *Lisp_Symbol to get at the
> actual struct correct?

No, Emacs never reinterprets Lisp_Objects, as they have a tag.

> Or am I misunderstanding how this works?

Yes.  There are several tagging schemes used to associate Lisp_Objects
with their types.  Usually, if a platform can provide the proper
alignment requirements, the least significant 3 bits of the word type
(configured at build-time) are used to a tag containing type
information.  After the tag bit is removed, Lisp_Objects are either
pointers to the corresponding Lisp_Foo struct, integers, or symbols,
which are actually offsets from the start of the auto-generated
`lispsym' array in global.h.  The first element of that array is nil,
and the tag bit for the symbol type is 0, so XSYMBOL naturally returns
the correct `nil' Lisp_Symbol for the integer 0.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]