added: `#import` at function scope; bugfix: numerous
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 25 Mar 2023 04:03:32 +0000 (23:03 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 25 Mar 2023 04:04:28 +0000 (23:04 -0500)
47 files changed:
compiler/src/clone.c
compiler/src/lex.c
compiler/src/parser.c
compiler/src/symres.c
core/builtin.onyx
core/conv/format.onyx
core/intrinsics/atomics.onyx
core/io/stdio.onyx
core/misc/any_utils.onyx
core/onyx/cptr.onyx
core/os/file.onyx
core/random/random.onyx
core/runtime/info/helper.onyx
core/runtime/platform/onyx/platform.onyx
core/runtime/platform/wasi/env.onyx
core/runtime/platform/wasi/wasi_fs.onyx
core/string/string.onyx
docs/bugs
examples/04_fixed_arrays.onyx
examples/05_slices.onyx
examples/06_dynamic_arrays.onyx
examples/07_structs.onyx
examples/08_enums.onyx
examples/10_switch_statements.onyx
examples/11_map.onyx
examples/12_varargs.onyx
examples/13_use_keyword.onyx
examples/14_overloaded_procs.onyx
examples/15_polymorphic_procs.onyx
examples/16_pipe_operator.onyx
examples/17_operator_overload.onyx
examples/18_macros.onyx
examples/19_do_blocks.onyx
examples/20_auto_return.onyx
examples/21_quick_functions.onyx
examples/22_interfaces.onyx
examples/50_misc.onyx
tests/aoc-2020/day1.onyx
tests/aoc-2020/day10.onyx
tests/aoc-2020/day11.onyx
tests/hello_world.onyx
tests/if_expressions.onyx
tests/interfaces.onyx
tests/multiple_returns_robustness.onyx
tests/new_printf.onyx
tests/overload_with_autocast.onyx
tests/string_stream_test.onyx

index f0c02fab6b7b9929211f4e5d5569212fe9e24dd9..28b8f64af11b6bb2b877f88db3b692392bb258ce 100644 (file)
@@ -117,6 +117,7 @@ static inline i32 ast_kind_to_size(AstNode* node) {
         case Ast_Kind_Directive_Remove: return sizeof(AstDirectiveRemove);
         case Ast_Kind_Directive_First: return sizeof(AstDirectiveFirst);
         case Ast_Kind_Directive_Export_Name: return sizeof(AstDirectiveExportName);
+        case Ast_Kind_Import: return sizeof(AstImport);
         case Ast_Kind_Count: return 0;
     }
 
index 4458c485822904fb348f52db0b27958a3118a673..7bf9aa1fec322f129057816ee83e5745f2b54a8b 100644 (file)
@@ -38,7 +38,6 @@ static const char* token_type_names[] = {
     "macro",
     "interface",
     "where",
-    "import",
     "", // end
 
     "->",
index 2cf8a1a091359940e75a083dd10e80cd72dd107e..174566f301b8f111595c77a0f1a8abfdc4fbad65 100644 (file)
@@ -566,6 +566,7 @@ static AstTyped* parse_factor(OnyxParser* parser) {
         }
 
         case Token_Type_Keyword_Package: {
+            onyx_report_warning(peek_token(-1)->pos, "Use of deprecated feature: package expression.");
             retval = (AstTyped *) parse_package_expression(parser);
             break;
         }
@@ -1498,6 +1499,7 @@ static AstNode* parse_use_stmt(OnyxParser* parser) {
     AstUse* use_node = make_node(AstUse, Ast_Kind_Use);
     use_node->token = use_token;
     use_node->expr = parse_expression(parser, 1);
+    if (!use_node->expr) return NULL;
 
     if (consume_token_if_next(parser, '{')) {
         bh_arr_new(global_heap_allocator, use_node->only, 4);
@@ -1726,6 +1728,14 @@ static AstNode* parse_statement(OnyxParser* parser) {
                 break;
             }
 
+            if (parse_possible_directive(parser, "import")) {
+                // :LinearTokenDependent
+                retval = (AstNode *) parse_import_statement(parser, parser->curr - 2);
+                ENTITY_SUBMIT(retval);
+                needs_semicolon = 0;
+                break;
+            }
+
             if (next_tokens_are(parser, 2, '#', Token_Type_Symbol)) {
                 retval = (AstNode *) parse_factor(parser);
                 break;
index e75a09bbb97e618207d6c7fe55402c4134fa48cc..6dd4299ce2224f3e650174e0f7fb4cb4ec51c2f5 100644 (file)
@@ -974,6 +974,10 @@ static SymresStatus symres_statement(AstNode** stmt, b32 *remove) {
             SYMRES(use, (AstUse *) *stmt);
             break;
 
+        case Ast_Kind_Import:
+            if (remove) *remove = 1;
+            break;
+
         default: SYMRES(expression, (AstTyped **) stmt); break;
     }
 
index fd6a49047db8800423871f5b3d22a17f5c63c4aa..69fd374ddde567275c3be4764f24bae49224dd2c 100644 (file)
@@ -2,10 +2,6 @@ package builtin
 
 #import runtime
 
-#if #defined(package core) {
-    #import core
-}
-
 //
 // Explanation of `package builtin`
 //
@@ -201,6 +197,8 @@ default_log_level :: (level: Log_Level) {
 
 #if runtime.runtime != .Custom {
     #local default_logger_proc :: (logger: &Default_Logger, level: Log_Level, msg: str, module: str) {
+        #import core;
+
         if level < logger.minimum_level do return;
 
         if module {
@@ -267,12 +265,14 @@ cfree   :: (ptr: rawptr)            => raw_free(context.allocator, ptr);
 // This cannot be used in a custom runtime, as the other core
 // packages are not included.
 #if runtime.runtime != .Custom {
+    #import core
+    #import core.memory
+
     new :: #match #local {}
 
     #overload
     new :: ($T: type_expr, allocator := context.allocator) -> &T {
-        use package core.intrinsics.onyx { __initialize }
-        memory :: package core.memory
+        use core.intrinsics.onyx { __initialize }
 
         res := cast(&T) raw_alloc(allocator, sizeof T);
         memory.set(res, 0, sizeof T);
@@ -283,8 +283,7 @@ cfree   :: (ptr: rawptr)            => raw_free(context.allocator, ptr);
 
     #overload
     new :: (T: type_expr, allocator := context.allocator) -> rawptr {
-        memory :: package core.memory
-        type_info :: package runtime.info
+        type_info :: runtime.info
 
         info := type_info.get_type_info(T);
         size := type_info.size_of(T);
@@ -451,12 +450,12 @@ Code :: struct {_:i32;}
 // remove some confusion around the 3 different array types as dynamic arrays would clearly just be
 // normal structures. With the recent addition of macros and iterators, there really wouldn't be much
 // difference anyway.
-#if #defined((package core.map).Map) {
-    Map :: (package core.map).Map;
+#if #defined(core.map.Map) {
+    Map :: core.map.Map;
 }
 
-#if #defined((package core.set).Set) {
-    Set :: (package core.set).Set;
+#if #defined(core.set.Set) {
+    Set :: core.set.Set;
 }
 
 
index 90b702342f0820b3ef3706317844d071e88f0bd6..fee0e326ee1c3fa21cdcec4f655ce9b53ec05414 100644 (file)
@@ -21,7 +21,7 @@ custom_formatters_initialized :: #init () {
     map.init(&custom_parsers,    default=null_proc);
 
     #if Enable_Custom_Formatters {
-        use package runtime.info;
+        use runtime.info;
 
         for type_idx: type_table.count {
             type := type_table[type_idx];
index ed00b212ae6f428260638884f59b658a0184d005..e10d26f78d41b0155b8da303eefdf02133d1f658 100644 (file)
@@ -1,7 +1,7 @@
 package core.intrinsics.atomics
 
 #local {
-    runtime :: package runtime
+    #import runtime
 
     #if !runtime.Multi_Threading_Enabled {
         #error "Multi-threading is not enabled so you cannot include the 'core.intrinsics.atomics' package."
index 8e5f602ac93cc7bb0a1c787bba995c6c45706c41..4d313039ee575582b6e735df10ad40eb4366a126 100644 (file)
@@ -1,8 +1,8 @@
 // Currently, these symbols are dumped in the 'core' namespace, which means
-// most programs that just 'use package core' can access all of them, which
+// most programs that just 'use core' can access all of them, which
 // is convenient; However, it doesn't hurt to wonder if they should be the
 // 'core.io' package so these would become like 'io.printf(...)'. Of course,
-// you could always still do 'use package core.io', which would bring these
+// you could always still do 'use core.io', which would bring these
 // in anyway.
 package core
 
index 88789a31813e4f89ce91198c533adf98876f8632..c1850f9b7f1ee0ca859331ca48a398aaac6e1f1b 100644 (file)
@@ -127,7 +127,7 @@ any_to_map :: (v: any) -> (Map(str, any), success: bool) {
 any_iter :: (arr: any) -> Iterator(any) {
     base_ptr, elem_type, count := any_as_array(arr);
     if count == 0 {
-        return .{ null, ((_) => any.{}, false) };
+        return .{ null, ((_: rawptr) => any.{}, false) };
     }
 
     return iter.generator(
index 6a474648193531e06b6354211a2fcfeb18b58cf0..210a2fb14854403a45f15f4eff50fcaaa83d6574 100644 (file)
@@ -70,7 +70,7 @@ cptr :: struct (T: type_expr) {
         // to the same idea as 'null' in Onyx.
         if this.data == 0 do return null;
 
-        wasm :: package core.intrinsics.wasm
+        #import core.intrinsics.wasm
         // Using 1 instead of 0 because a null pointer (0) converts
         // to the memory address 0, not the base address for the WASM
         // memory.
index 9cfd9eaec4ba575b414cda24f52218235db02017..27dbeac7ad682972dd6e3b9e2f968943cdd64582 100644 (file)
@@ -9,7 +9,8 @@ package core.os
 
 use core
 
-#local fs :: package runtime.platform
+
+#local fs :: runtime.platform
 
 
 FileError :: enum {
index 00df5f73658d883a4361f03484ce21032ebcd73c..1431dfa725cbb32a97895c0c3c4592598e4182bc 100644 (file)
@@ -1,5 +1,7 @@
 package core.random
 
+#import core
+
 //
 // The state of a random number generator.
 Random :: struct {
@@ -52,7 +54,7 @@ Random :: struct {
     // Returns a random string of length `bytes_long`. If `alpha_numeric` is
     // true, then the string will only consist of alpha-numeric characters.
     string :: (self: &Random, bytes_long: u32, alpha_numeric := false, allocator := context.allocator) -> str {
-        memory :: package core.memory
+        #import core.memory
 
         s := memory.make_slice(u8, bytes_long, allocator=allocator);
         for& s {
index 39b85bf29bd61114191737f74f2f23a6288b99e0..bae2f9aae32d81a0688be3bf38a96d283c3d8bfb 100644 (file)
@@ -331,8 +331,10 @@ populate_struct_vtable :: (table: &$Table_Type, struct_type: type_expr, safe :=
 }
 
 for_all_types :: macro (body: Code) {
+    #import runtime
+
     for runtime.info.type_table.count {
-        type_info := (package runtime.info).type_table[it];
+        type_info := runtime.info.type_table[it];
         type_idx  : type_expr = ~~ it;
 
         #unquote body;
index 8fa49b97ce187b59f2348515dcc758420348a75b..55e2c55fc3247b13288eb1cae945471c5c2a73e5 100644 (file)
@@ -2,6 +2,7 @@ package runtime.platform
 
 #import core
 #import runtime
+#import main
 
 use core
 use runtime {
@@ -104,8 +105,8 @@ __start :: () {
     __runtime_initialize();
     context.thread_id = 0;
 
-    #if (typeof (package main).main) == #type () -> void {
-        (package main).main();
+    #if (typeof main.main) == #type () -> void {
+        main.main();
 
     } else {
         args : [] cstr;
@@ -116,7 +117,7 @@ __start :: () {
         argv_buf := cast(cstr) calloc(argv_buf_size);
         __args_get(args.data, argv_buf);
 
-        (package main).main(args);
+        main.main(args);
     }
 
     __flush_stdio();
index c1f7db363c601f5107a04f2be9bc27a9f7d783b1..24d8f0e7755a1f5e25894306bed6ac4025666bb5 100644 (file)
@@ -1,16 +1,19 @@
 package core.env
 
-#local runtime :: package runtime
+#import runtime
+#import core.map
+#import core.memory
+#import core.string
+#import wasi
+
+
 #if runtime.runtime != .Wasi 
     && runtime.runtime != .Onyx {
     #error "'core.env' is only available with the 'wasi' and 'onyx' runtimes.";
 }
 
 
-use package wasi { environ_get, environ_sizes_get, Size }
-#package map    :: package core.map
-#package memory :: package core.memory
-#package string :: package core.string
+use wasi { environ_get, environ_sizes_get, Size }
 
 Environment :: struct {
     vars             : Map(str, str);
index c8ee8b205590915a3e7a088af940bbaeb3afb2d2..6fcd7f337f5408f203a7c6b7e59b2ab23570dc8a 100644 (file)
@@ -1,14 +1,16 @@
 package runtime.platform
 
-#local runtime :: package runtime
+#import runtime
+#import core
+#import wasi
+
+use core
+
 #if runtime.runtime != .Wasi {
     #error "The file system library is currently only available on the WASI runtime, and should only be included if that is the chosen runtime."
 }
 
-use package core
-
-#local wasi :: package wasi
-use package wasi {
+use wasi {
     FileDescriptor,
     FDFlags, OFlags, Rights,
     LookupFlags, Errno,
index e643d84078ec7ef9f5207d66bb57ae88e6a6463c..bc45d71df6c88d162a55a3dc79a98ec0cb35fc45 100644 (file)
@@ -654,37 +654,45 @@ bisect :: (s: str, substr: str) -> (str, str) {
 //
 
 to_dyn_str :: (x: str, allocator := context.allocator) -> dyn_str {
-    return (package core.array).make(x, allocator);
+    #import core.array
+    return array.make(x, allocator);
 }
 
 delete  :: macro (x: &dyn_str, idx: u32) -> u8 {
-    return (package core.array).delete(x, idx);
+    #import core.array
+    return array.delete(x, idx);
 }
 
 append  :: #match {
     macro (x: &dyn_str, other: str) {
-        (package core.array).concat(x, other);
+        #import core.array
+        array.concat(x, other);
     }, 
 
     macro (x: &dyn_str, other: u8) {
-        (package core.array).push(x, other);
+        #import core.array
+        array.push(x, other);
     }, 
 }
 
 clear   :: macro (x: &dyn_str) {
-    (package core.array).clear(x);
+    #import core.array
+    array.clear(x);
 }
 
 retreat :: macro (x: &dyn_str, chars := 1) {
-    (package core.array).pop(x, chars);
+    #import core.array
+    array.pop(x, chars);
 }
 
 insert  :: #match #locked {
     macro (x: &dyn_str, idx: u32, new_str: str) -> bool {
-        return (package core.array).insert(x, idx, new_str);
+        #import core.array
+        return array.insert(x, idx, new_str);
     },
 
     macro (x: &dyn_str, idx: u32, ch: u8) -> bool {
-        return (package core.array).insert(x, idx, ch);
+        #import core.array
+        return array.insert(x, idx, ch);
     }
 }
index 10d44f07c6b2b4c4f9ec7fc7b6637ee27ef159bc..bc05602891e7a1c5d867fd233556581b0d662fc6 100644 (file)
--- a/docs/bugs
+++ b/docs/bugs
@@ -125,7 +125,7 @@ List of known bugs:
     use_package_breaking :: () {
         println("Test 1");
 
-        use package foo
+        use foo
 
         println("Test 2");
     }
index b68f91dc8e68d4d0851110b8328c0443035751a7..393c3928d623d28e1354450a016ef1b094345e9e 100644 (file)
@@ -17,7 +17,8 @@
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
     // The following declares a fixed-size array of 10 i32s on the stack. Currently,
index 1cc792ade6a3e54464dc68ee27f16766504f116f..085f1c51370aab5ee1a20aa907a4d134998ac2d3 100644 (file)
@@ -7,7 +7,8 @@
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
     // A dummy array to demonstrate.
index b307a414a0b2fa3efd567e6028fa683735b34589..2825d4cc83e396a2ce6ec319bd47265c9822ea1b 100644 (file)
@@ -9,7 +9,8 @@
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
     // Declaring dynamic arrays in Onyx looks like this. The
index ff2b59267b4176ce8d412ecc51cb3c534f61b2f7..e7bd2e43cdf538006eac84cf4cc96d73ef3e68ed 100644 (file)
@@ -7,7 +7,8 @@
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
 
index 63449417fea75903b4a5058e39e4f8a28e226c93..bc145828e61ccf21a90c1e622e31f7ac9bf5c54d 100644 (file)
@@ -6,7 +6,8 @@
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
     // To declare a simple, use the enum keyword.
index 9c9bec6c8b2372070c070e76b257a0dc3d729dcf..cbfce52648e10fa1fb0180784105bd7e0de8afe9 100644 (file)
@@ -1,6 +1,7 @@
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
     x := 10 + 3 * 5;
index cc75c9fab69fb940c4e988c66015503aaf2e6252..d3c9c6cc184b7b101b851db3588db7f9b4e90ae3 100644 (file)
@@ -1,6 +1,7 @@
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
     // Onyx does not have map type built into the language semantics,
index 12bf339ebced9f569aa8b8ea9243ae7dd5a852b3..649c5fda3d371c13236e0fbb600422b909a05a09 100644 (file)
@@ -17,7 +17,8 @@
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
 
index cb30eac094251940d1f2a830e4c25bd3ee4c1eae..7edf73b382eaab5856699adc06a596fd3a8939e6 100644 (file)
@@ -16,7 +16,8 @@
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
     // Here are the uses of 'use' currently.
@@ -25,15 +26,15 @@ main :: (args: [] cstr) {
         // You can 'use' a package. You hopefully already knew this.
         // This brings in all the symbols from the core.alloc package into
         // this scope.
-        use package core.alloc
+        use core.alloc
 
         // You can also restrict and partially rename the symbols that collide
-        use package core.string { string_free :: free }
+        use core.string { string_free :: free }
     }
 
     {
         // You can also 'use' a package that is a subpackage of another package. Here, 'string'
-        // is a subpackage of 'core' and the above 'use package core' makes this package
+        // is a subpackage of 'core' and the above 'use core' makes this package
         // available for you to write code like 'string.equal(...)'. However, because it is
         // a namespace, you can 'use' it.
         use string
index f60e9ae890ddfbb7748ff6c36d09214d8832607a..c555e6932359f1e08994829bdd31ab003af9fe44 100644 (file)
@@ -34,7 +34,8 @@
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
     // See the overloaded procedure defined below.
index c0e7013d1120783f978965026183633c127c749f..6fb1300dc61b0e2987fb8e882d71307b348631df 100644 (file)
@@ -59,7 +59,8 @@ compose :: (a: $A, f: (A) -> $B, g: (B) -> $C) -> C {
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
 }
index 107da554e33697306e90f35f254a3f56b4889428..ba69e6d8ed95b233f0d7807ed6b78ad9697c4027 100644 (file)
@@ -1,6 +1,7 @@
 #load "core/std"
 
-use package core { println }
+#import core
+use core { println }
 
 main :: (args: [] cstr) {
     // These functions will be used to demo the pipe operator.
@@ -34,4 +35,4 @@ main :: (args: [] cstr) {
     // It is not an operator you probably will not have to use very
     // often; But when you have code like the first println above,
     // it can clean up the code and make it easier to read.
-}
\ No newline at end of file
+}
index 96cac6a383f5453d4e0bb764dd30467c2b3873ec..091c66b4ca93703a499d26a38df13dc58d7dfc0c 100644 (file)
@@ -1,5 +1,6 @@
 #load "core/std"
-use package core
+#import core
+use core
 
 // Operator overloading allows you to define what it means to perform
 // a binary operation between two types. In Onyx, they are defined in
index bc5941bf39985841490eeb249ccfa0b129a20a0b..e01ae472e84c00dcef3ecef14961e742110454f4 100644 (file)
@@ -135,4 +135,5 @@ main :: (args: [] cstr) {
 }
 
 #load "core/std"
-use package core
\ No newline at end of file
+#import core
+use core
index 80631ecb698ecede6365ea2e0fe07d5b907bc807..b4f47106c503dd921674034380d85290ea21a5aa 100644 (file)
@@ -66,4 +66,5 @@ main :: (args: [] cstr) {
 }
 
 #load "core/std"
-use package core
+#import core
+use core
index 041397008c59a804e824da5baf2fa46d10a84ea3..b72800f45381ecb4e04ea491a8e0a5cdc3b8494c 100644 (file)
@@ -43,5 +43,6 @@ main :: (args: [] cstr) {
 }
 
 #load "core/std"
-use package core
+#import core
+use core
 
index d43abc843a19f9380fa32f5c6989cedfb05fce32..bac0dc17ebb994bf865f3cc6696380987213cce6 100644 (file)
@@ -45,4 +45,5 @@ main :: (args) => {
 }
 
 #load "core/std"
-use package core
+#import core
+use core
index 1bf958afecce30f727eeca6e1fabe167690d7296..5a0da1e8b8fdda4a86df0a290f5c76972f761210 100644 (file)
@@ -135,6 +135,6 @@ main :: (args) => {
 }
 
 #load "core/std"
-
-use package core
-use package core.intrinsics.onyx
+#import core
+use core
+use core.intrinsics.onyx
index 4b0e4b753d79f028d72d1ed30db1a3581d9cf434..193c6bdb8208c6112850495f1133a8a1b3967865 100644 (file)
@@ -67,4 +67,5 @@ main :: (args) => {
 }
 
 #load "core/std"
-use package core
+#import core
+use core
index 7162889a655762103612f5afa20cf4c4a4d2c3e0..1547b17f70b85e75a59b141a014c691fe578c7c8 100644 (file)
@@ -1,6 +1,9 @@
 #load "core/std"
 
-use package core
+#import core
+#import core.io
+#import core.array
+use core {printf}
 
 main :: (args: [] cstr) {
     contents := #file_contents "./tests/aoc-2020/input/day1.txt";
index 8866633a6262b1e239be5948f1440ed35d938ea8..ca1a654a67dde991c8a1f293c83511b34a5f40aa 100644 (file)
@@ -1,6 +1,7 @@
 #load "core/std"
 
-use package core
+#import core
+use core
 
 count_ending_paths :: (nums: [..] u32) -> u64 {
     tally := array.make(u64, nums.count);
index ca09764b67ef725eae0b85f7c832f57e03bc61c5..f6ede0ffd20bee0f8a8acea57356ff018b0ef70d 100644 (file)
@@ -1,6 +1,7 @@
 #load "core/std"
 
-use package core
+#import core
+use core
 
 GameOfSeats :: struct {
     width  : u32;
index 88198e4f97c854df908b55b3fd003c5d7348aab8..d69e04b625b4f7ab8e2528502ab09da9f784512e 100644 (file)
@@ -2,7 +2,8 @@ package main
 
 #load "core/std"
 
-use package core
+#import core
+use core
 
 main :: (args: [] cstr) {
     println("Hello, World!");
index 050a26e172a2d3d2093447430aa9986a1665e8b2..b42b89b954aeda56a9fa924a59159c0e306199d1 100644 (file)
@@ -1,6 +1,7 @@
 #load "core/std"
 
-use package core
+#import core
+use core {println, printf}
 
 some_function :: () -> f32 {
     println("In some function!");
@@ -27,4 +28,4 @@ main :: (args: [] cstr) {
 
     v: V2 = (.{ 10, 20 }) if true else .{ 30, 40 };
     printf("{}\n", v);
-}
\ No newline at end of file
+}
index 83a2a92f6bc6bfde99dd97ea43c380a5a8fe4a92..5134c42b11ff3dbaa208123d89b01996ba502cf2 100644 (file)
@@ -1,6 +1,12 @@
 #load "core/std"
 
-use package core
+#import core
+#import core.hash
+#import core.conv
+#import core.array
+#import core.iter
+
+use core {println, printf}
 
 Hashable :: interface (t :$T) {
     { hash.to_u32(t) } -> u32;
index 9ee7330ec9dbd630504874e35d2bedf8e860f63e..8400200a273d46fae67e7946b8a17a9f866bcce9 100644 (file)
@@ -1,6 +1,7 @@
 #load "core/std"
 
-use package core
+#import core
+use core
 
 foo :: () -> (i32, i32) {
     return 50, 60;
index 197308683a160fb373c3e5ff86a92adc415479ba..07711f83df5754749fb091c39c7c07cfbd5019c1 100644 (file)
@@ -1,7 +1,7 @@
 #load "core/std"
 
-use package core
+#import core
 
 main :: (args: [] cstr) {
-    printf("{} {} {{}} {} {.1} {.5} {}\n", 123, "Test", false, 12.34, 12.3456789, [..] map.Map(i32, str));
+    core.printf("{} {} {{}} {} {.1} {.5} {}\n", 123, "Test", false, 12.34, 12.3456789, [..] map.Map(i32, str));
 }
index 2328fdb27ff343be9b4d3c2e99cee2fac9d2bbd3..93ee4ee63ef56826dcf3477571469f01eecc02a1 100644 (file)
@@ -1,6 +1,7 @@
 #load "core/std"
 
-use package core
+#import core
+use core {println}
 
 overloaded :: #match {
     (x: str, y: i32) do println("Called str, i32"); ,
index 0e97c8702508caea5199e86b03ea21d1bd2b6a98..1eabe6359607cf2b98fac27311a6af7a2112c2f5 100644 (file)
@@ -1,6 +1,8 @@
 #load "core/std"
 
-use package core
+#import core
+#import core.io
+use core {println}
 
 main :: (args: [] cstr) {
     some_string := "This is a test string that can be read.\n\n\n\n\n\n1234 4567";