NXXX7
T[..;] — Non-owning Sized Arrays for Spans and Beyond

Published Proposal,

Previous Revisions:
None
Authors:
Paper Source:
GitHub
Issue Tracking:
GitHub
Project:
ISO/IEC 9899 Programming Languages — C, ISO/IEC JTC1/SC22/WG14
Proposal Category:
Change Request, Feature Request
Target:
C2y/C3a

Abstract

Modeled after the fix for what Walter Bright called "C’s biggest mistake", this proposal explores an extended variant of a non-owning span type which can unify the processing of arrays, whether they’re C arrays, a bespoke combination of a pointer and a size, a variable-length array, or other source/region of memory. The syntax, T[..], and it’s expansive alternative that allows for an infinite amount of dimensions and strides within a single memory region, T[..; spec], allow for code to very clearly model the semantics of a flat buffer of memory.

1. Changelog

2. Introduction and Motivation

Ouiaf. :3

Wef! :3

3. Design

The syntax of this type is as specified below.

Syntax Dimensions Memory Regions Minimum Storage required
T a[..] 1 1 1 pointer, 1 size
T a[..][2] 2 2 (1 pointer, 1 size) * 2
T a[..][..] 2 1 * N (1 pointer, 1 size) * N
T a[..; ..] 1 1 1 pointer, 1 size
T a[..; .., 4] 2 1 1 pointer, 1 size
T a[..; .., ..] 2 1 1 pointer, 2 sizes
T a[..; 3, .., 2] 3 1 1 pointer, 1 size
T a[..; .., .., ..] 3 1 1 pointer, 3 sizes