diff options
| author | gingerBill <bill@gingerbill.org> | 2020-05-15 18:45:24 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-05-15 18:45:24 +0100 |
| commit | e1bdaa981adf14b5caf4346e154a3a66bce8ccd7 (patch) | |
| tree | 990d5ceeea04c6a56efda4ee2a5a55580c4a7377 /examples | |
| parent | 95e8668b779ec59d9e0a3afefb51d599c6602cd2 (diff) | |
Relative pointer and relative slices
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/demo/demo.odin | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin index 4f425b698..e6882fbcc 100644 --- a/examples/demo/demo.odin +++ b/examples/demo/demo.odin @@ -1938,10 +1938,29 @@ dummy_procedure :: proc() { explicit_context_definition :: proc "c" () { // Try commenting the following statement out below - context = runtime.default_context(); + context = runtime.default_context(); + + fmt.println("\n#explicit context definition"); dummy_procedure(); } +relative_data_types :: proc() { + fmt.println("\n#relative data types"); + + x: int = 123; + ptr: #relative(i16) ^int; + ptr = &x; + fmt.println(ptr^); + + arr := [3]int{1, 2, 3}; + s := arr[:]; + rel_slice: #relative(i16) []int; + rel_slice = s; + fmt.println(rel_slice); + fmt.println(rel_slice[:]); + fmt.println(rel_slice[1]); +} + main :: proc() { when true { the_basics(); @@ -1973,5 +1992,6 @@ main :: proc() { constant_literal_expressions(); union_maybe(); explicit_context_definition(); + relative_data_types(); } } |