Skip to content

live scalar field views - #76

Merged
saidctb merged 11 commits into
mainfrom
codex/live-scalar-field-views
Sep 27, 2026
Merged

saidctb merged 11 commits into
mainfrom
codex/live-scalar-field-views

Conversation

@saidctb

@saidctb saidctb commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

No description provided.

saidctb and others added 2 commits September 27, 2026 14:12
Scalar allocatable and pointer fields of a derived type, numeric or
character, now read as live read-only rank-zero views or None and are
assigned through an allocating or target copy, the way the matching module
variables are. They previously failed to build. Pointer holders now report
fields they cannot reach as a policy diagnostic instead of failing during
planning, and the generated .pyi constructor no longer lists these fields.

The README's Fortran limitations drop assumed-rank type(*) buffers and the
now-supported fields, and end every item with a full stop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scalar fields of a Fortran derived type now read as live rank-zero NumPy
views of the object's storage, the way module variables do: numeric and
logical fields as T[()] views and fixed-length character fields as
fixed-width bytes views, spelled T[()] and String[n][()] in generated
contracts. An edited contract that keeps a plain T or String[n] field still
reads a copied value. Direct objects, module-object members, and objects
held through allocatable or pointer descriptors all lend the same storage.

Scalar allocatable and pointer module variables and fields now lend
writable views, matching allocatable and pointer array views: a view is
valid until native code reallocates, deallocates, or reassociates it, and
assigning the attribute still reaches the current storage.

The bridge's field dispatchers become table dispatch over named builders,
and one address-capture reader in the planner serves both backends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saidctb saidctb changed the title Codex/live scalar field views live scalar field views Sep 27, 2026
saidctb and others added 9 commits September 27, 2026 16:16
Fortran character(kind=selected_char_kind('ISO_10646')) declarations are
wrapped through the new UString contract type, which takes every form
String does and maps fixed-width storage to NumPy U<n> instead of S<n>.
Kinds that select ASCII or DEFAULT are ordinary Strings; a compiler without
ISO_10646 is reported as not providing the character set.

String and UString share one path. The type name carries the character
width, one helper answers whether a type is a string and how wide its
characters are, and every stage reads that width: the bridge declares the
matching character kind and sizes byte buffers, the binding selects the
UTF-8 or UCS-4 codec, NumPy dtype, and itemsize, and the runtime helpers
take the width. For the default kind every stage emits the code it did
before. A UCS-4 str input is converted into the call buffer mutable strings
already use, because a str holds no UCS-4 storage to lend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mber

Kind numbers are processor-dependent, so character(kind=4) no longer means
UCS-4; only selected_char_kind('ISO_10646'), directly or through a parameter,
selects UString. A known selector keeps its spelling instead of being
replaced by its probed number, which now only reports a compiler lacking the
set. Function results resolve their character selector against module
parameters the way arguments already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… sets

A numeric character kind such as kind=4 names whichever character set the
target compiler numbers that way. Semantic requirement collection now asks
the probe for selected_char_kind('DEFAULT'), 'ASCII', and 'ISO_10646', and
the converter builds one compiler-specific map from kind number to String or
UString. A number the compiler assigns to none of them is refused with a
message saying so. Selector spellings are still classified by the set they
name, without a probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and planner

The allocatable- and pointer-holder field lowerings in the bridge and the
binding differed only in holder type, capsule, and symbol names, so each
backend now lowers holder fields once. Private field methods share one
owner-argument parser, stored-field getters share one view builder, string
validation is one function for both character widths, and field entrypoints
share one operation and character-buffer constructor. Generated sources are
byte-identical for every fixture in the test corpus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@saidctb
saidctb merged commit 0a9bd10 into main Sep 27, 2026
4 checks passed
@saidctb
saidctb deleted the codex/live-scalar-field-views branch September 27, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant