Home /Modules/comparison/TYPE-AND-VALUE-MAPPING.md

TYPE-AND-VALUE-MAPPING.md

comparison/TYPE-AND-VALUE-MAPPING.md · 56 line(s) · markdown

Type and Value Mapping

Standard SCS-TYPE-001 | Edition 1.0

1. Purpose

Mappings identify conceptual counterparts. They do not assert identical memory layout, ABI, or behavior.

2. Primitive comparison

ConceptSLeeLaJavaCC++
BooleanSLeeLa boolean contractboolean_Bool (C99+)bool
8-bit signedExplicit SLeeLa widthbyteint8_t, if providedstd::int8_t, if provided
16-bit signedExplicit SLeeLa widthshortint16_tstd::int16_t
32-bit signedint32intint32_tstd::int32_t
64-bit signedint64; verify int aliaslongint64_tstd::int64_t
32-bit floatfloatfloatfloatfloat
64-bit floatdoubledoubledoubledouble
CharacterSLeeLa character contract16-bit UTF-16 code unit charinteger character typeschar, char8_t, char16_t, char32_t, wchar_t
StringSLeeLa String contractimmutable UTF-16 Stringno built-in stringlibrary string types

SLeeLa Syntax 3.0 documents signed and unsigned width families. Verify actual implementation and precision for each width; a type name alone does not prove a native slot or full-precision behavior.

3. Integers

For each type record bit width, signedness, range, literal rules, promotion, overflow, division/remainder, shifts, conversions, and serialization byte order.

Java primitive integer widths are fixed. C/C++ fundamental integer widths depend on implementation; exact-width types are optional where the implementation provides them. Unsigned C/C++ arithmetic is modulo the corresponding width. Signed overflow in C/C++ is not a portable wrapping contract. Java integer arithmetic has defined fixed-width behavior. SLeeLa rules must come from its normative syntax/VM specifications and tests.

4. Floating point

Test finite values, signed zero, infinities, NaN, subnormals, rounding, conversions, and fused operations separately. Record precision and tolerance. Bitwise equality requires an explicitly fixed representation and operation sequence.

5. Characters and strings

Do not equate a byte, character, code unit, Unicode code point, or grapheme cluster. Java char is a UTF-16 code unit; supplementary code points use surrogate pairs. C/C++ char is a byte-sized storage unit, not necessarily a Unicode character. UTF-8 is a sequence of encoded bytes.

SLeeLa must document encoding, indexing unit, length unit, normalization, invalid-sequence behavior, and whether indexing may split a multi-unit character. Convert explicitly at boundaries.

6. Arrays and collections

ConcernSLeeLaJavaCC++
Fixed arraySLeeLa array contractallocated array objectnative arraynative array / std::array
Dynamic sequenceSLeeLa collectionArrayList/collectionsexplicit allocation and lengthstd::vector/containers
BoundsVM/runtime contractchecked for Java arraysraw arrays not automatically checkedraw arrays not automatically checked
OwnershipVM/lifetime rulesmanaged referencesprogrammer-definedRAII and/or explicit

Never pass a managed array as a raw C pointer without a documented pin/copy, lifetime, and bounds contract.

7. Records and objects

Java objects have identity and managed lifetime. C structs have ABI-defined layout, padding, and alignment. C++ classes may include constructors, destructors, virtual dispatch, inheritance, and ABI-sensitive features. SLeeLa mappings must state whether the boundary uses a copy, opaque handle, serialized record, or explicit C structure.

8. Conversion classes

Classify every conversion as exact/lossless, range-checked, narrowing, sign-changing, precision-losing, encoding conversion, ownership transfer, or prohibited. Never silently truncate, reinterpret pointers, change signedness, or transfer ownership.

9. Interchange

Portable files and network messages must define field widths, signedness, byte order, encoding, framing, version, and validation. Prefer versioned serialization to dumping native structures. Do not persist native padding or pointers.

10. Required tests

Cover min/max values, conversion boundaries, overflow, negative values, zero, array bounds, string encoding, and serialization with exact compiler/runtime versions.