diff --git a/doc/kc3/2. Integer.en.md b/doc/kc3/2. Integer.en.md
index 5ec89dc..4b6b2b4 100644
--- a/doc/kc3/2. Integer.en.md
+++ b/doc/kc3/2. Integer.en.md
@@ -1,10 +1,6 @@
----
-title: 2. Integers
----
+# 2 Integers
-# Integers
-
-## Small integers
+## 2.1 Small integers
IKC3 supports all C integer type sizes from `U8` (matching the C type `uint8_t`)
to `U64` (matching the C type `uint64_t`) for unsigned integers,
@@ -44,7 +40,7 @@ ikc3> type(18446744073709551615)
U64
```
-## Large integers
+## 2.2 Large integers
IKC3 supports large integers and they are compatible with small integers.
Their type is `Integer` and can support numbers as large as memory allows.
@@ -57,9 +53,9 @@ Integer
```
-## Operations on integers
+## 2.3 Operations on integers
-### Operator `~`
+### 2.3.1 Operator `~`
Binary not.
@@ -78,7 +74,7 @@ ikc3> ~ (S16) 1
-2
```
-### Operator `+`
+### 2.3.2 Operator `+`
Integer addition.
@@ -92,31 +88,31 @@ zero or a positive integer, and one. E.g.
etc.
```
-### Operator `-`
+### 2.3.3 Operator `-`
Integer subtraction. Take an integer and remove another integer from it.
-### Operator `*`
+### 2.3.4 Operator `*`
Integer multiplication. Init result to zero, add an integer `a` and
repeat `b` times.
-### Operator `/`
+### 2.3.5 Operator `/`
Integer division. The inverse of multiplication :
for all integers `a` and `b` there is a couple `q` and `r` that satisfies
`a = b * q + r`. Integer division returns `q`.
-### Operator `mod`
+### 2.3.6 Operator `mod`
Integer modulo. Returns `r` in the previous equation (see Operator `/`)
-### Operator `<<`
+### 2.3.7 Operator `<<`
Left shift
-# Examples
+## 2.4 Examples
```
ikc3> type(1)
diff --git a/doc/kc3/3. Map.en.md b/doc/kc3/3. Map.en.md
index 3c17511..27cc576 100644
--- a/doc/kc3/3. Map.en.md
+++ b/doc/kc3/3. Map.en.md
@@ -1,8 +1,4 @@
----
-title: 3. Map
----
-
-# Maps
+# 3 Map
KC3 maps are like Elixir maps, they are key-values enclosed in `%{}` :
diff --git a/doc/kc3/4. Ratio.en.md b/doc/kc3/4. Ratio.en.md
index 39f7c67..0b889ce 100644
--- a/doc/kc3/4. Ratio.en.md
+++ b/doc/kc3/4. Ratio.en.md
@@ -1,8 +1,4 @@
----
-title: 4. Ratio
----
-
-# Ratios
+# 4 Ratio
Ratios are made with a couple of large integers : the numerator
which can be any number, and the denominator which has to be positive.
diff --git a/doc/kc3/5. List.en.md b/doc/kc3/5. List.en.md
index adf816e..259d1b1 100644
--- a/doc/kc3/5. List.en.md
+++ b/doc/kc3/5. List.en.md
@@ -1,9 +1,12 @@
-# Module List
+# 5 List
+
+Linked lists owning the data (each node contains a couple of tags :
+one for data and one for next pointer.
Regular lists can be :
- - an element and a list : `[1 | [2]]`
- multiple elements : `[1, 2, 3]`
- - multiple elements and a list : `[1, 2 | [3, 4]]`
+ - an element and a list : `[1 | [2, 3]]`
+ - multiple elements and a list : `[1, 2 | [3]]`
- the empty list : `[]`
Regular lists end with the empty list : `[1] == [1 | []]`.
@@ -16,7 +19,7 @@ the next list pointer is an arbitrary form. E.g. :
All these list formats are supported in pattern matching.
-## Functions
+## 5.1 Functions
```
List List.map (List, Fn)
diff --git a/doc/kc3/6. Variable.en.md b/doc/kc3/6. Variable.en.md
index 5d12c8d..0536c0e 100644
--- a/doc/kc3/6. Variable.en.md
+++ b/doc/kc3/6. Variable.en.md
@@ -1,6 +1,6 @@
-# Variables
+# 6 Variables
-Variables in C3 can be defined using the litteral value for a variable
+Variables in KC3 can be defined using the litteral value for a variable
which is always `?`. You can cast this litteral value and it will not
really be casted but it will give you a typed variable litteral value.
E.g. `(List) ?`.
@@ -12,7 +12,7 @@ It's actually a syntax so you cannot rename `?` by mistake and
so is an easy task to do static analysis of variable creation.
The default type for a variable which you can also specify explicitly
-is `Tag` which is an enum-tagged union type of any other C3 types
+is `Tag` which is an enum-tagged union type of any other KC3 types
currently defined in the environment. So `?` is exactly equivalent to
`(Tag) ?` and they will both accept to be set once to one value of any
type.
@@ -37,7 +37,7 @@ that should accept this C function definition :
`quote cfn unquote(type) unquote("init_#{variable_type}#{init_suffix}") (Result, ...)`.
There are many functions for this, here is a quick list :
- `tag_init_1` takes a C string as an argument and returns a value of
- any type currently defined in the C3 environment.
+ any type currently defined in the KC3 environment.
- `#{type}_init_1` C functions take a C string as an argument and return
a value of type `type`.
- `tag_init_copy` takes a tag as an argument and returns a deep copy
diff --git a/http/url.c b/http/url.c
index 87beb1a..1c7f3d5 100644
--- a/http/url.c
+++ b/http/url.c
@@ -43,11 +43,11 @@ s_str * url_escape (const s_str *src, s_str *dest)
return NULL;
s = *src;
while (str_read_character_utf8(&s, &c) > 0) {
- /*if (c == ' ') {
- if (buf_write_u8(&buf, '+') < 0)
- goto clean;
- }
- else*/
+ /* if (c == ' ') {
+ if (buf_write_u8(&buf, '+') < 0)
+ goto clean;
+ }
+ else */
if (str_character_position(escapes, c) >= 0) {
if (buf_write_u8(&buf, '%') < 0)
goto clean;
@@ -92,9 +92,9 @@ sw url_escape_size (const s_str *src)
escapes = &escapes_tag.data.str;
s = *src;
while ((r = str_read_character_utf8(&s, &c)) > 0) {
- /*if (c == ' ')
- result += 1;
- else*/
+ /* if (c == ' ')
+ result += 1;
+ else */
if (str_character_position(escapes, c) >= 0)
result += 3;
else
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index fc59467..9b6571c 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -251,35 +251,28 @@ s_str * kc3_getenv (const s_str *name, s_str *dest)
s_tag * kc3_if_then_else (const s_tag *cond, const s_tag *then,
const s_tag *else_, s_tag *dest)
{
- s_call cond_cast = {0};
- s_tag tmp = {0};
- call_init_call_cast(&cond_cast, &g_sym_Bool);
- if (! tag_init_copy(&list_next(cond_cast.arguments)->tag, cond)) {
- call_clean(&cond_cast);
- return NULL;
- }
- if (! env_eval_call(&g_kc3_env, &cond_cast, &tmp)) {
- call_clean(&cond_cast);
- return NULL;
- }
- if (tmp.type != TAG_BOOL) {
- tag_clean(&tmp);
- call_clean(&cond_cast);
+ bool cond_bool;
+ s_tag cond_eval = {0};
+ const s_sym *type;
+ if (! env_eval_tag(&g_kc3_env, cond, &cond_eval))
return NULL;
- }
- if (tmp.data.bool) {
- if (! env_eval_tag(&g_kc3_env, then, dest)) {
- call_clean(&cond_cast);
+ if (cond_eval.type == TAG_BOOL)
+ cond_bool = cond_eval.data.bool;
+ else {
+ type = &g_sym_Bool;
+ if (! bool_init_cast(&cond_bool, &type, &cond_eval)) {
+ tag_clean(&cond_eval);
return NULL;
}
- call_clean(&cond_cast);
+ }
+ tag_clean(&cond_eval);
+ if (cond_bool) {
+ if (! env_eval_tag(&g_kc3_env, then, dest))
+ return NULL;
return dest;
}
- if (! env_eval_tag(&g_kc3_env, else_, dest)) {
- call_clean(&cond_cast);
+ if (! env_eval_tag(&g_kc3_env, else_, dest))
return NULL;
- }
- call_clean(&cond_cast);
return dest;
}
diff --git a/test/httpd/assets/css/c3.scss b/test/httpd/assets/css/c3.scss
deleted file mode 100644
index 2c09da7..0000000
--- a/test/httpd/assets/css/c3.scss
+++ /dev/null
@@ -1,50 +0,0 @@
-body.C3 {
- margin: 0;
- padding: 0;
- width: 100%;
- background: url('/_images/iris-c3-004.jpeg');
- background-size: 100%;
- background-position-y: 2.9rem;
-
- div.container {
- margin: 0;
- padding: 0;
- width: 100%;
- max-width: 100%;
- }
-
- h1 {
- position: relative;
- display: block;
- margin: 0 auto;
- width: 20%;
- height: 0;
- padding: 0 0 20% 0;
- background: url('/_images/c3.256.png');
- background-size: 100%;
- }
-
- .C3-1 {
- position: relative;
- display: block;
- margin: 10% 0 33% 4%;
- padding: 0 0 40% 0;
- width: 45%;
- height: 0;
- border-radius: 1rem;
- background: #fff;
- font-size: 1.8vw;
-
- & > div {
- margin: 0;
- padding: 3vw;
- }
- }
-
- div.pixels-5-15 {
- div.container {
- margin: 0 auto;
- max-width: 540px;
- }
- }
-}
diff --git a/test/httpd/assets/css/kc3.scss b/test/httpd/assets/css/kc3.scss
new file mode 100644
index 0000000..5f187ca
--- /dev/null
+++ b/test/httpd/assets/css/kc3.scss
@@ -0,0 +1,50 @@
+body.KC3 {
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ background: url('/_images/iris-kc3-004.jpeg');
+ background-size: 100%;
+ background-position-y: 2.9rem;
+
+ div.container {
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ max-width: 100%;
+ }
+
+ h1 {
+ position: relative;
+ display: block;
+ margin: 0 auto;
+ width: 20%;
+ height: 0;
+ padding: 0 0 20% 0;
+ background: url('/_images/kc3.256.png');
+ background-size: 100%;
+ }
+
+ .KC3-1 {
+ position: relative;
+ display: block;
+ margin: 10% 0 33% 4%;
+ padding: 0 0 40% 0;
+ width: 45%;
+ height: 0;
+ border-radius: 1rem;
+ background: #fff;
+ font-size: 1.8vw;
+
+ & > div {
+ margin: 0;
+ padding: 3vw;
+ }
+ }
+
+ div.pixels-5-15 {
+ div.container {
+ margin: 0 auto;
+ max-width: 540px;
+ }
+ }
+}