removed outdated doc paragraph about functions

This commit is contained in:
Francesco Cozzuto
2021-12-01 00:11:57 +01:00
parent da61b1a9d9
commit fba9698b8b
2 changed files with 1 additions and 68 deletions
-42
View File
@@ -276,45 +276,3 @@ As an example, the `print` function always returns `none`
```py
print(print()); # none
```
Functions are always "pure", in the sense that the only values that the
function body can access are the ones provided as arguments. Usually in
other languages, functions can access the global scope and the parent
scope (closures). There's no such mechanism in this language (at the
moment).
The only exception is made for the "built in" variables, which are
provided by the runtime of the language and can't be modified by the
user. The print function is one of these variables. One may override
these variables but the effect only lasts for the lifetame of the
context local to the assignment.
```py
# Overwrite the print variable inside the global
# scope..
print = 5;
# The reference to the print function is lost
# withing this scope.
fun test()
{
# If the previous assignment were to overwrite the
# print function globally, the next statement would
# fail because the value 5 isn't a function. But
# it doesn't fail!
print('Not overwritten here!\n');
}
test();
# We can take the reference to the print function
# by taking it from a function!
fun get_print_back()
return print;
print = get_print_back();
print('Hei! Print is back!\n');
```
+1 -26
View File
@@ -9,29 +9,4 @@ fun fail(p)
assert(false);
}
#fail(0);
defined_globally = 111;
fun A()
{
print('Hello from A!\n');
defined_in_A = 10;
fun B()
{
defined_in_B = 33;
print('Hello from B!\n');
print('defined_globally = ', defined_globally, '\n');
print('defined_in_A = ', defined_in_A, '\n');
print('defined_in_B = ', defined_in_B, '\n');
}
B();
print('defined_in_B = ', defined_in_B, '\n');
}
A();
fail(0);