Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

valor collection defaults

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Missing list, map, and set fields extracted from value receive usable empty collection handles.

Syntax: <valor-expression> ↦ <genus-type>

Category#

conversion

Examples#

radix/corpus/reference/conversio/valor-collection-defaults/valor-genus-collections.fab (canonical · conversio)#

Missing list, map, and set fields extracted from value receive usable empty collection handles.

# value ↦ class — seed missing supported collection fields with empty handles
#
# Runtime-owned collection fields require real handles, not null pointers.
# Missing list, map, and set fields extracted from `value` therefore start as
# usable empty collections, while JSON's mandatory-field policy is unchanged.

class EmptyCollections {
    mut list<int> items
    mut map<string, int> index
    mut set<int> keys
}

main {
    let value source ← { "unused": 0 } ↦ value
    let EmptyCollections extracted ← source ↦ EmptyCollections
    print extracted.items.length()
    print extracted.index.length()
    print extracted.keys.length()
}

Expected output:

0
0
0