Commit 057582ef authored by Phuntsok Drak-pa's avatar Phuntsok Drak-pa

Some clarifications about scopes and shadowing

parent 22433262
......@@ -55,6 +55,8 @@ As you can see above, comments are marked with the symbol ~$~, which makes any c
Literal values can be given as-is, however their type will be inferred by the compiler and it might not infer the type the user wished for, hence it is recommended to use the built-in functions related to these types, such as ~Int(i: () -> int) -> int;~ which ensures that ~i~ is an ~int~. By default, an ~int~ is an signed integer on eight (8) bytes, similar to Rust’s ~i64~.
Identifiers live through their scope, which is either the file if they are declared at its root, or the function in which they are declared, such as function arguments or functions declared within other functions. If an identifier is declared in a function which already provides said identifier, the latter is shadowed by the declaration of the former for the rest of its scope. Hence in the functions ~a~, ~b~, and ~res~ in the example above, the identifier ~i~ declared as their argument will be different from ~i~ declared as an argument of the function ~fib~. However since ~i~ of ~a~, ~b~, and ~res~ was declared as an argument for each, it will not overwrite the initial argument of ~fib~ and will only live in the function in which it was declared. An identifier can be overwritten with the operator ~=~ followed by a function declaration without a name given after the ~make~ keyword.
* Types
** Types available
- int :: signed integer coded on four (4) bytes, similar to Rust’s ~i32~. Default integer, can be obtained with the built-in function ~Int(i: () -> int) -> int;~
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment