tiny changes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 27 Apr 2021 01:49:17 +0000 (20:49 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 27 Apr 2021 01:49:17 +0000 (20:49 -0500)
core/stdio.onyx
examples/08_enums.onyx
examples/13_use_keyword.onyx

index c0540a1874de871f144356aa839289fb5b2d1afd..7488a5a4b04ba9fe8b4a60344da2edd2a20c7ae6 100644 (file)
@@ -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");
     }
 
 
index dc55b55e04b34285ac5546c06ffb6389d706774e..0262ea2da3342e10acd1726c3642d16eb56ebf50 100644 (file)
@@ -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");
+        }
+    }
 }
index 760a81a25837c05bbe83c1f58ac74e97a87fbe1b..7c6e5380d0e77152d8c898543414f08f79490df1 100644 (file)
@@ -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.
     }
 }