blob: 121a4159e40071af1c1eae8922583876dded95a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
string type
===========
what other programming languages / stdlibs do or have done:
- shortstrings (byte length + merged data) [old Pascal]
- modifiable refcounted (refcount + length + pointer) [new Pascal]
- raw null-terminated [C]
- immutable object, garbage collected (length + pointer) [Java]
# With a enum it requires an extra field!
type String = case (
.ShortString (
byte length,
[length]byte data,
)
.MergedString (
size length,
[length]byte data,
)
.MergedZString (
# TODO
),
.CompressedString (
# we need a compression algo that:
# - decompresses quickly
# - does not need much overhead for dictionaries etc.
# - is suitable for deterministic compression (like UTF-8 there might be overlongs)
size clength,
[length]byte data,
)
.ReadOnlyView (
size length,
ref [length]byte data,
)
)
# we can have an immutable string type as a standard string type
# and another type that allows modification, and can be converted to an immutable string
|