Re: unboxed structure fields (or class slots)

"wojciech.pasieka (as wojciech dot pasieka at ai dot pressiton dot com)" <[email protected]> (Adrian W. Pasieka)
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
Gemini's says both: 'YES' and 'NO'.

This part of answer is interesting:
'I would need access to the specific machine code generation patterns of the LispWorks 8.x or 9.x compiler (the versions relevant in 2026) and the internal representation of defstruct objects.'


Is it feasible to connect LLM-s to the machine code, to support Lispworks in technical queries..?


Kind Regards,
Adrian W. Pasieka


-------------------------------------------------------
1. Can LispWorks handle unboxed doubles in structures?

To answer this definitively, I would need access to the specific machine code generation patterns of the LispWorks 8.x or 9.x compiler (the versions relevant in 2026) and the internal representation of defstruct objects.

The Short Answer: No (strictly speaking), but Yes (effectively).

In a standard defstruct or defclass, LispWorks generally cannot store an unboxed double-float directly in a slot. This is because the LispWorks Garbage Collector (GC) expects slots to contain tagged pointers. If you put a raw 64-bit float in a slot, the GC might mistake it for a memory address and crash when trying to "trace" it.

However, there are "Yes" cases via workarounds:

    Specialized Arrays: If you store your doubles in a (make-array size :element-type 'double-float), LW handles these as unboxed, contiguous blocks of memory.

    The FLI (Foreign Function Interface): You can define a C-style struct using fli:define-foreign-struct. These slots are strictly unboxed. Accessing them is fast, but you lose some high-level Lisp features (like standard slot inheritance).

    Local Optimization: As suggested in the snippet, using (declare (type double-float ...))
    inside a lexical scope allows the compiler to keep a value in a CPU register (unboxed) for the
    duration of the calculation. The "boxing" only happens when you write the result back into a
    standard structure slot.
-------------------------------------------------------------------------------------------------
(unnamed) (message/rfc822, 4.7 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.