diff options
| author | Ginger Bill <bill@gingerbill.org> | 2016-09-29 00:42:26 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2016-09-29 00:42:26 +0100 |
| commit | 04b5d8c132e8aabb3bb5dff31683cb45d4dff9c0 (patch) | |
| tree | e8a13d736022bd50e85f324eb5186d1ca00f0ea1 /code | |
| parent | 6e39a42c8a090d6e32231872cc292c90de6b304e (diff) | |
using on indexable field; Auto deref for (Index|Slice)Expr
Diffstat (limited to 'code')
| -rw-r--r-- | code/demo.odin | 64 |
1 files changed, 11 insertions, 53 deletions
diff --git a/code/demo.odin b/code/demo.odin index 14f9f5b54..c517169b0 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -3,59 +3,17 @@ #import "hash.odin" #import "mem.odin" -main :: proc() { - { // New Standard Library stuff - s := "Hello" - fmt.println(s, - utf8.valid_string(s), - hash.murmur64(s.data, s.count)) - - // utf8.odin - // hash.odin - // - crc, fnv, fnva, murmur - // mem.odin - // - Custom allocators - // - Helpers - } - - { - arena: mem.Arena - mem.init_arena_from_context(^arena, mem.megabytes(16)) // Uses default allocator - defer mem.free_arena(^arena) - - push_allocator mem.arena_allocator(^arena) { - x := new(int) - x^ = 1337 - - fmt.println(x^) - } - - /* - push_allocator x { - ... - } - - is equivalent to this: - { - prev_allocator := current_context().allocator - current_context().allocator = x - defer current_context().allocator = prev_allocator - - ... - } - */ - - // You can also "push" a context - - c := current_context() - c.allocator = mem.arena_allocator(^arena) - - push_context c { - x := new(int) - x^ = 365 +A :: struct { using e: [12]int } +Vector2 :: raw_union { + using _xy: struct #ordered { x, y: f32 } + using v: {2}f32 + e: [2]f32 +} - fmt.println(x^) - } - } +main :: proc() { + v: Vector2 + v.x = 123 + v[1] = 321 + fmt.println(v) } |