removed outdated doc paragraph about functions
This commit is contained in:
@@ -275,46 +275,4 @@ 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');
|
||||
```
|
||||
Reference in New Issue
Block a user