diff options
-rw-r--r-- | documentation/typing.md | 39 |
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. |