aboutsummaryrefslogtreecommitdiff
path: root/documentation
diff options
context:
space:
mode:
authorChimrod <>2023-09-24 18:49:32 +0200
committerChimrod <>2023-09-24 18:49:32 +0200
commit6827f5ddc2a6636d26660de43024aa5742d99d03 (patch)
treec7af5732eb09348ba2c05f79b551a72f8f49e2f2 /documentation
parentfe03a99d7b95af45390db69eca3a67ba9ad5ffad (diff)
Updated the type system documentation
Diffstat (limited to 'documentation')
-rw-r--r--documentation/typing.md39
1 files changed, 38 insertions, 1 deletions
diff --git a/documentation/typing.md b/documentation/typing.md
index 57b792d..9639ac8 100644
--- a/documentation/typing.md
+++ b/documentation/typing.md
@@ -77,7 +77,7 @@ table, a text will always be greater than a number (`'a' > 9999` will return
## Explicit conversion
-### From string to num
+### From string to integer
`isnum(…)` will tell you if a value is an integer or not:
@@ -93,3 +93,40 @@ val('123') -> 123
val('abc') -> 0 ! No error here
```
+### From integer to string
+
+`str(…)` will convert a number in string.
+
+## QSP Syntax Parser
+
+> [!NOTE]
+> This parts describe how QSP Syntax Parser deal with the type system. This is
+> not a part of the language reference.
+
+### No implicit conversion
+
+*Explicit is better than implicit.*
+
+Implicit conversion is a bad thing. It can raise errors during the game if you
+don’t care, and can hide other error in the code:
+
+This code is valid, but does not work as expected (because of a `$` is missing
+in the if clause, `$myvar` and `myvar` are two differents variables):
+
+```
+$myvar = 'VALUE'
+…
+if myvar = 'VALUE':
+ …
+```
+
+In order to spot this kind of errors, a warning will be raised here.
+
+### The boolean type
+
+I’ve added a boolean type which does not exists in the original syntax. In QSP,
+the value `-1` stand for `True` and `0` for `False.`
+
+Because *Readability counts.* , the application will raise a warning if a
+String or an integer is directly given in an if clause. A comparaison operator
+is required.