refactor: migrate examples to import Std::Io instead of raw extern func
- Create stdlib/Std/Io.bux with extern func declarations
- Rename C shim functions to short names (PrintLine, PrintInt, etc.)
- Update all 9 examples to use import Std::Io::{PrintLine, PrintInt};
- Remove manual extern func Std_Io_* declarations from examples
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Algebraic Enums - Enums with data (tagged unions)
|
||||
extern func Std_Io_PrintLine(s: String);
|
||||
extern func Std_Io_PrintInt(n: int);
|
||||
import Std::Io::{PrintLine, PrintInt};
|
||||
|
||||
|
||||
enum Result {
|
||||
Ok(int),
|
||||
@@ -15,14 +15,14 @@ func Main() -> int {
|
||||
r2.data.Err_0 = "error message";
|
||||
|
||||
if r1.tag == Result_Ok {
|
||||
Std_Io_PrintLine("r1 is Ok:");
|
||||
Std_Io_PrintInt(r1.data.Ok_0);
|
||||
Std_Io_PrintLine("");
|
||||
PrintLine("r1 is Ok:");
|
||||
PrintInt(r1.data.Ok_0);
|
||||
PrintLine("");
|
||||
}
|
||||
|
||||
if r2.tag == Result_Err {
|
||||
Std_Io_PrintLine("r2 is Err:");
|
||||
Std_Io_PrintLine(r2.data.Err_0);
|
||||
PrintLine("r2 is Err:");
|
||||
PrintLine(r2.data.Err_0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user