diff options
| author | Ginger Bill <bill@gingerbill.org> | 2016-08-30 23:32:04 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2016-08-30 23:32:04 +0100 |
| commit | cda0234d487ab73a1c87cbdcd74e300718ca7d0a (patch) | |
| tree | bf7ccddca7a7c0146cfdba35ab731f93edd25201 /examples | |
| parent | a06f70d5d95bb7889bf9e8b920d70fd10daf7c12 (diff) | |
Subtyping Polymorphic arguments; `using` procedure parameters
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/demo.odin | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/examples/demo.odin b/examples/demo.odin index 84845a3e0..81362301e 100644 --- a/examples/demo.odin +++ b/examples/demo.odin @@ -3,26 +3,28 @@ #load "game.odin" main :: proc() { + Vec3 :: type struct { x, y, z: f32 } + Entity :: type struct { + using pos: Vec3 + name: string + } - Thing :: type struct { - using x: struct { a, b: int } + Frog :: type struct { + using entity: Entity + jump_height: f32 } - { - using t := new(Thing) - defer delete(t) - a = 321 - print_int(a); nl() + f := Frog{} + f.name = "ribbit" + + print_name :: proc(using e: Entity) { + print_string(name); nl() } - // { - // using t := new(Thing) - // defer delete(t) - // a = 1337 - // print_int(a); nl() - // } + print_name(f.entity) + print_name(f) + - // run_game() } |