aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-06-14 11:43:35 +0100
committergingerBill <bill@gingerbill.org>2021-06-14 11:43:35 +0100
commit3e7aabe6d83797f7451300a5c8e6fb4a5c1804d2 (patch)
tree1d478a40ae1ac927846700c1d130ab4ce639607e /examples
parentd4df325e0a2cfe1d6de90667099d9ac43e269029 (diff)
Change uses for parapoly records to use `$` always
Diffstat (limited to 'examples')
-rw-r--r--examples/demo/demo.odin11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin
index af67df3e9..cbffc1956 100644
--- a/examples/demo/demo.odin
+++ b/examples/demo/demo.odin
@@ -898,14 +898,14 @@ parametric_polymorphism :: proc() {
{ // Polymorphic Types and Type Specialization
- Table_Slot :: struct(Key, Value: typeid) {
+ Table_Slot :: struct($Key, $Value: typeid) {
occupied: bool,
hash: u32,
key: Key,
value: Value,
};
TABLE_SIZE_MIN :: 32;
- Table :: struct(Key, Value: typeid) {
+ Table :: struct($Key, $Value: typeid) {
count: int,
allocator: mem.Allocator,
slots: []Table_Slot(Key, Value),
@@ -1042,7 +1042,7 @@ parametric_polymorphism :: proc() {
Foo2,
Foo3,
};
- Para_Union :: union(T: typeid) {T, Error};
+ Para_Union :: union($T: typeid) {T, Error};
r: Para_Union(int);
fmt.println(typeid_of(type_of(r)));
@@ -1594,7 +1594,7 @@ where_clauses :: proc() {
}
{ // Record types
- Foo :: struct(T: typeid, N: int)
+ Foo :: struct($T: typeid, $N: int)
where intrinsics.type_is_integer(T),
N > 2 {
x: [N]T,
@@ -1949,7 +1949,8 @@ constant_literal_expressions :: proc() {
union_maybe :: proc() {
fmt.println("\n#union #maybe");
- Maybe :: union(T: typeid) #maybe {T};
+ // NOTE: This is already built-in, and this is just a reimplementation to explain the behaviour
+ Maybe :: union($T: typeid) #maybe {T};
i: Maybe(u8);
p: Maybe(^u8); // No tag is stored for pointers, nil is the sentinel value