Skip to content

Type Layout functions added to compiler to better support C-FFI.#229

Open
redvers wants to merge 3 commits into
mainfrom
type_layout_instrinsics
Open

Type Layout functions added to compiler to better support C-FFI.#229
redvers wants to merge 3 commits into
mainfrom
type_layout_instrinsics

Conversation

@redvers

@redvers redvers commented May 2, 2026

Copy link
Copy Markdown
Contributor

Proposes a TypeInfo primitive with four compile-time intrinsics — size_of, stride_of, align_of, offset_of — exposing layout information LLVM already computes. Covers concrete nominal types (primitives, structs, classes, actors) and tuples; unions and other abstract types are compile-time errors.

@ponylang-main ponylang-main added discuss during sync Should be discussed during an upcoming sync status - new The RFC is new and ready for discussion. and removed discuss during sync Should be discussed during an upcoming sync labels May 2, 2026
@redvers redvers added the discuss during sync Should be discussed during an upcoming sync label May 6, 2026
Comment thread text/0000-type-layout-intrinsics.md Outdated
Comment thread text/0000-type-layout-intrinsics.md Outdated
Comment thread text/0000-type-layout-intrinsics.md Outdated
Comment thread text/0000-type-layout-intrinsics.md Outdated
Comment thread text/0000-type-layout-intrinsics.md Outdated
- Rename TypeInfo primitive to ABIMemoryLayout to avoid builtin name
  collisions (jemc/adrianboyko consensus).
- Replace offset_of[T](field: String) with offsets_of[T]() returning
  Array[(String, USize)] val (adrianboyko's proposal). Removes the
  literal-string special case from the compiler and unifies the four
  intrinsics under one validation shape; the single-field-lookup
  ergonomic is recovered with a small user-side helper.
- Drop nested-path unresolved question and embed-specific testing
  language; no special handling of embedded fields, per sync call.
- Reword the misleading "round-tripping" stride_of example.
- Replace the generic-serializer example, which called a nonexistent
  field_value(name) method, with an honest layout-inspection example.
- Document the rejected offset_of(field: String) design as an
  alternative.
@SeanTAllen

Copy link
Copy Markdown
Member

@redvers please ask a robot to reformat this to have no breaking lines except for paragraphs etc. or suffer and do it yourself. i think you should "ask a robot".

@redvers redvers force-pushed the type_layout_instrinsics branch from b6e483a to 563f9e9 Compare May 27, 2026 05:13
@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status - new The RFC is new and ready for discussion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants