diff --git a/.ikc3_history b/.ikc3_history
index 462d6a8..83f57e0 100644
--- a/.ikc3_history
+++ b/.ikc3_history
@@ -1,14 +1,3 @@
-if true then true end
-if 42 then true end
-if 0 then true end
-if 0 then true else false end
-List.map
-List.map([1, 2, 3], fn (x) { x * 2 })
-List.reverse
-List.reverse([1, 2, 3])
-List.reverse
-List.reverse([1, 2])
-def a = 1
a
module()
defmodule Plop do
@@ -97,3 +86,14 @@ type(op.id)
type(op.sym)
(Str) op.sym
[fd: (S32) -1]
+load("https://git.kmx.io/kc3-lang/kc3/
+)
+load("lib/kc3/0.1/s32.facts")
+(S32) 1
+(S32) -1
+[fd: (S32) -1]
+defmodule Socket do defstruct [fd: (S32) -1]; end
+defmodule Socket do
+dlopen("lib/kc3/0.1/http.so")
+def connect = cfn Socket.Buf "socket_buf_init_connect" (Result, Str, Str)
+end
diff --git a/lib/kc3/0.1/buf.kc3 b/lib/kc3/0.1/buf.kc3
index 5d11df3..0f6dc02 100644
--- a/lib/kc3/0.1/buf.kc3
+++ b/lib/kc3/0.1/buf.kc3
@@ -1,16 +1,16 @@
defmodule Buf do
- defstruct [column: Sw,
- flush: Ptr,
- free: Bool,
- line: Sw,
- ptr: Ptr,
- refill: Ptr,
- rpos: Uw,
- save: Ptr,
- seek: Ptr,
- size: Uw,
- user_ptr: Ptr,
- wpos: Uw]
+ defstruct [column: (Sw) 0,
+ flush: (Ptr) 0,
+ free: false,
+ line: (Sw) 0,
+ ptr: (Ptr) 0,
+ refill: (Ptr) 0,
+ rpos: (Uw) 0,
+ save: (Ptr) 0,
+ seek: (Ptr) 0,
+ size: (Uw) 0,
+ user_ptr: (Ptr) 0,
+ wpos: (Uw) 0]
end
diff --git a/lib/kc3/0.1/kc3.facts b/lib/kc3/0.1/kc3.facts
index e9cd39f..d8d57be 100644
--- a/lib/kc3/0.1/kc3.facts
+++ b/lib/kc3/0.1/kc3.facts
@@ -28,7 +28,7 @@ replace {KC3.operator_defstruct, :symbol, :defstruct}
replace {KC3.operator_defstruct, :arity, 1}
replace {KC3.operator_defstruct, :symbol_value, cfn Tag "kc3_defstruct" (List, Result)}
replace {KC3.operator_defstruct, :operator_precedence, 12}
-replace {KC3.operator_defstruct, :operator_associativity, :right}
+replace {KC3.operator_defstruct, :operator_associativity, :none}
add {KC3, :operator, KC3.operator_pin}
replace {KC3.operator_pin, :is_a, :operator}
replace {KC3.operator_pin, :symbol, :^}
@@ -50,6 +50,13 @@ replace {KC3.operator_not, :arity, 1}
replace {KC3.operator_not, :symbol_value, cfn Bool "tag_not" (Tag, Result)}
replace {KC3.operator_not, :operator_precedence, 12}
replace {KC3.operator_not, :operator_associativity, :right}
+add {KC3, :operator, KC3.operator_require}
+replace {KC3.operator_require, :is_a, :operator}
+replace {KC3.operator_require, :symbol, :require}
+replace {KC3.operator_require, :arity, 1}
+replace {KC3.operator_require, :symbol_value, cfn Tag "kc3_require" (List, Result)}
+replace {KC3.operator_require, :operator_precedence, 12}
+replace {KC3.operator_require, :operator_associativity, :none}
add {KC3, :operator, KC3.operator_div}
replace {KC3.operator_div, :is_a, :operator}
replace {KC3.operator_div, :symbol, :/}
diff --git a/lib/kc3/0.1/ptr.facts b/lib/kc3/0.1/ptr.facts
index 7d7a113..e57f6a9 100644
--- a/lib/kc3/0.1/ptr.facts
+++ b/lib/kc3/0.1/ptr.facts
@@ -2,4 +2,4 @@
version: 1}
replace {Ptr, :is_a, :module}
replace {Ptr, :symbol, Ptr.cast}
-replace {Ptr.cast, :symbol_value, cfn Ptr "ptr_init_cast" (Result, Tag)}
+replace {Ptr.cast, :symbol_value, cfn Ptr "ptr_init_cast" (Result, Sym, Tag)}
diff --git a/lib/kc3/0.1/socket/buf.kc3 b/lib/kc3/0.1/socket/buf.kc3
index 0f0f816..78992dc 100644
--- a/lib/kc3/0.1/socket/buf.kc3
+++ b/lib/kc3/0.1/socket/buf.kc3
@@ -1,8 +1,8 @@
defmodule Socket.Buf do
defstruct [buf_rw: %BufRW{},
- sockfd: S32,
+ sockfd: (S32) -1,
addr: %Socket.Addr{},
- addr_len: U32]
+ addr_len: (U32) 0]
end
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index 22cb80a..6f9056b 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -240,6 +240,11 @@ sw kc3_puts (const s_tag *tag)
return result;
}
+bool kc3_require (const s_sym * const *module)
+{
+ return env_module_ensure_loaded(&g_kc3_env, *module);
+}
+
s_list ** kc3_search_modules (s_list **dest)
{
return env_search_modules(&g_kc3_env, dest);
diff --git a/libkc3/kc3_main.h b/libkc3/kc3_main.h
index f48d1f0..c6f8a32 100644
--- a/libkc3/kc3_main.h
+++ b/libkc3/kc3_main.h
@@ -52,6 +52,7 @@ void ** kc3_dlopen (const s_str *path, void **dest);
void kc3_exit (sw code);
bool kc3_load (const s_str *path);
s_tag * kc3_pin (const s_tag *a, s_tag *dest);
+bool kc3_require (const s_sym * const *module);
/* Special operators. */
s_tag * kc3_if_then_else (const s_tag *cond, const s_tag *then,