it will work on many systems. ARM / PowerPC may not work correctly.
* procedures can be polymorphic on an array size.
* structures can be polymorphic on any compile-time known value.
-* procedures can be polymoprhic on any compile-time known value, including type expressions.
+* procedures can be polymorphic on any compile-time known value, including type expressions.
* basics of operator overloading using `#operator +`.
* multiple return values and multiple assignment / declarations.
* #solidify directive for explicitly specifying type variables in polymorphic procs.
value, but one that was still computed at the assignment site. Now, they instead are used to
declare top level expressions in the procedure scope. This means that things like structs and
enums can be declared at any block scope. The top-level expressions currently do not have
- access to polymoprhic variables in the procedure.
+ access to polymorphic variables in the procedure.
* `#include_file` is now `#load` and `#include_folder` is now `#load_path`. I like the shorter names.
* enum values are compile time known.
* struct literals are compile time known can be used at top level scope.
Bug fixes:
* many bugs related to var args and procedure calls in general.
* polymorphic structs caused segmentation fault when trying to produce an error message.
-* polymorhpic structs caused scope to change when using a struct literal of a polymoprhic type.
+* polymorhpic structs caused scope to change when using a struct literal of a polymorphic type.
* #char "\"" did not work.
* nested function calls returning non-basic types would simply be wrong.
* Recursive structs are no longer possible.
return .None, fs;
}
+close :: (file: ^FileStream) {
+ file_close(file.file);
+ file.stream.vtable = null;
+}
+
#private
file_stream_vtable := Stream_Vtable.{
seek = (use fs: ^FileStream, to: i32, whence: SeekFrom) -> Error {
// These function are overloaded in order to use the builtin WASM intrinsics for the
-// operation first, and then default to a polymoprhic function that works on any type.
+// operation first, and then default to a polymorphic function that works on any type.
// The clunky part about these at the moment is that, if you wanted to pass 'max' to
// a procedure, you would have to pass 'max_poly' instead, because overloaded functions
// are not resolved when used by value, i.e. foo : (f32, f32) -> f32 = math.max; Even if
if x[x.count - 1] == #char "\n" && auto_flush_stdio do __flush_stdio();
},
- (x: $T) { io.write(^stdio.print_writer, x); },
- (x: $T, y: $R) { io.write(^stdio.print_writer, x, y); },
+ (x) => { io.write(^stdio.print_writer, x); },
+ (x, y) => { io.write(^stdio.print_writer, x, y); },
}
-println :: (x: $T) {
+println :: (x) => {
print(x);
print("\n");
}
if val.Property2 { ... }
```
- [X] #solidify polymoprhic procedures.
+ [X] #solidify polymorphic procedures.
API Expansion:
There are many different places where the standard API for WASI and JS
}
@Relocate
-move_towards :: (value: ^$T, target: T, step: T) {
+move_towards :: macro (value: ^$T, target: T, step: T) {
if *value < target do *value += step;
if *value > target do *value -= step;
if *value > target - step && *value < target + step do *value = target;
case Ast_Kind_Alias:
case Ast_Kind_Code_Block:
case Ast_Kind_Macro:
+ case Ast_Kind_File_Contents:
return 0;
default: return 1;
// Polymorphic Procedures
//
+// HACK HACK HACK nocheckin
+static b32 flag_to_yield = 0;
+
AstNode node_that_signals_a_yield = { 0 };
static void ensure_polyproc_cache_is_created(AstPolyProc* pp) {
}
// NOTE: These are temporary data structures used to represent the pattern matching system
-// of polymoprhic type resolution.
+// of polymorphic type resolution.
typedef struct PolySolveResult {
PolySolutionKind kind;
union {
} PolySolveElem;
// NOTE: The job of this function is to solve for the type/value that belongs in a
-// polymoprhic variable. This function takes in three arguments:
+// polymorphic variable. This function takes in three arguments:
// * The symbol node of the polymorphic parameter being searched for
// * The type expression that should contain the symbol node it is some where
// * The actual type to pattern match against
*resolved = solve_poly_type(param->poly_sym, param->type_expr, actual_type);
}
-// HACK HACK HACK nocheckin
-static b32 flag_to_yield = 0;
// NOTE: The job of this function is to look through the arguments provided and find a matching
// value that is to be baked into the polymorphic procedures poly-scope. It expected that param
}
if (already_solved) continue;
- // NOTE: Solve for the polymoprhic parameter's value
+ // NOTE: Solve for the polymorphic parameter's value
PolySolveResult resolved = { PSK_Undefined };
switch (param->kind) {
case PPK_Poly_Type: solve_for_polymorphic_param_type (&resolved, pp, param, pp_lookup, actual, err_msg); break;
// resolution was unsuccessful, provide a basic dummy one.
if (err_msg && *err_msg == NULL)
*err_msg = bh_aprintf(global_scratch_allocator,
- "Unable to solve for polymoprhic variable '%b'.",
+ "Unable to solve for polymorphic variable '%b'.",
param->poly_sym->token->text,
param->poly_sym->token->length);
}
// NOTE: The job of this function is to be a wrapper to other functions, providing an error
-// message if a solution could not be found. This can't be merged with polymoprhic_proc_solidify
-// because polymoprhic_proc_try_solidify uses the aforementioned function.
+// message if a solution could not be found. This can't be merged with polymorphic_proc_solidify
+// because polymorphic_proc_try_solidify uses the aforementioned function.
AstFunction* polymorphic_proc_lookup(AstPolyProc* pp, PolyProcLookupMethod pp_lookup, ptr actual, OnyxToken* tkn) {
ensure_polyproc_cache_is_created(pp);
case Ast_Kind_File_Contents: {
AstFileContents* fc = (AstFileContents *) expr;
+ assert(fc->addr > 0);
+ assert(fc->size > 0);
+
WID(WI_PTR_CONST, fc->addr);
WID(WI_I32_CONST, fc->size);
break;
main :: (args: [] cstr) {
// Hopefully soon, the following will be possible.
- // iterator := count_iterator(1, 10)
- // |> iter.map(x => x * 2)
- // |> iter.filter(x => x > 10)
- // |> iter.map(x => x + 42)
- // |> iter.take(5)
- // |> iter.to_array();
+/*
+ quick_iterator :=
+ count_iterator(1, 10)
+ |> iter.map((x) => x * 2)
+ |> iter.filter((x) => x > 10)
+ |> iter.map((x) => x + 42)
+ |> iter.take(5)
+ |> iter.to_array();
+
+ for v: quick_iterator {
+ println(v);
+ }
+*/
iterator := count_iterator(1, 10)
|> iter.map((x: i32) -> i32 { return x * 2; })