From f3e5a92249c1d6e92c3c5902f89dc49ce17a5e79 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 26 Apr 2021 20:49:17 -0500 Subject: [PATCH] tiny changes --- core/stdio.onyx | 4 ++-- examples/08_enums.onyx | 14 ++++++++++++++ examples/13_use_keyword.onyx | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/stdio.onyx b/core/stdio.onyx index c0540a18..7488a5a4 100644 --- a/core/stdio.onyx +++ b/core/stdio.onyx @@ -55,7 +55,7 @@ print_array :: proc { } } -byte_dump :: (ptr: rawptr, byte_count: u32) { +byte_dump :: (ptr: rawptr, byte_count: u32, bytes_per_line := 8) { temp: [3] u8; u8_ptr := cast(^u8) ptr; @@ -68,7 +68,7 @@ byte_dump :: (ptr: rawptr, byte_count: u32) { runtime.__output_string(.{ ~~temp, 3 }); - if i % 8 == 7 do runtime.__output_string("\n"); + if i % bytes_per_line == (bytes_per_line - 1) do runtime.__output_string("\n"); } diff --git a/examples/08_enums.onyx b/examples/08_enums.onyx index dc55b55e..0262ea2d 100644 --- a/examples/08_enums.onyx +++ b/examples/08_enums.onyx @@ -48,4 +48,18 @@ main :: (args: [] cstr) { println(cast(i32) FlaggedEnum.Value3); println(cast(i32) FlaggedEnum.Value4); print("\n"); + + { + // As a convenience, if the type of the enum can be determined from context, + // you can leave out the enum name from the lookup and just use a unary '.'. + // For example, + // + + val := SimpleEnum.Value2; + + // Here .Value2 can be resolved from the context of "val". + if val == .Value2 { + println("val is Value2"); + } + } } diff --git a/examples/13_use_keyword.onyx b/examples/13_use_keyword.onyx index 760a81a2..7c6e5380 100644 --- a/examples/13_use_keyword.onyx +++ b/examples/13_use_keyword.onyx @@ -94,6 +94,6 @@ main :: (args: [] cstr) { { // You can 'use' struct members that are structures. - // This is already explained in the struct example. + // This is already explained in the struct example. } } -- 2.25.1