|Page 80 of 800||Search internet|
The Logiweb programming language is univocal in the sense that if you invoke the same function on the same arguments two times, and if both invocations return a value in finite time, then the two return values are the same. In this connection, an exception counts as a value like any other value.
The language is pure functional in the sense of being univocal. But it does permit side effects like printing a value to the terminal or dying with a death report to the terminal.
The language has no functions for e.g. telling what time it is. A function which can tell what time it is would return different values each time it was called, and that would violate univocality. Likewise, the language has no functions for reading from the users terminal.
Do not use functions with side effects for programming; they are not portable. Use them for debugging only. If you want to write programs that do IO, learn about Logiweb machines.
Here are the functions for cheating, spying, and debugging:
One way to get debug output is to invoke it from a test case. Here are some examples you can try adding to append.lgs:
\item "[[ etst !"print" ; print ( << !"Hello" ,, !"World" >> ) end test ]]"
That prints 'HelloWorld' to the terminal. The argument of print is scanned left to right for strings and all strings are printed. The exclamation marks before strings ensure the strings are rendered as strings. That is not so important for strings that merely contain letters. The print function returns 'print' so the test succeeds.
You get no line feed after 'HelloWorld' because you did not ask for one. If you want a linefeed at the end you can use the constant LF:
print ( << !"Hello" ,, !"World" ,, LF >> )
Or you may use println instead of print:
println ( << !"Hello" ,, !"World" >> )
Println returns the string 'print'. Use LF even if your host operating system uses some other newline convention. It is the responsibility of lgc to adapt to the host operating system.
The trace function provides another means for getting debug output:
\item "[[ etst !"trace" ; trace ( << !"Hello" ,, !"World" >> ) end test ]]"
That prints something like this to the terminal:
The thing above is a pair operator P applied to the string 'Hello' and a second argument. The second argument comprises a pair operator P applied to the string 'World' and the constant T which represents .
\item "[[ etst !"timer" ; timer ( 0 ) end test ]]" \item "[[ etst !"timer" ; timer ( true ) end test ]]"
When lgc(1) terminates, it says goodbye. But afterwards, since lgc runs on top of the Logiweb Abstract Machine lgwam(1), you will get a death report from lgwam. The output may end something like this:
... User rendering Goodbye Values of timers Timer Calls Seconds 0 1 0.001331
The output above says that timer 1 was started one time and ran for 0.001331 seconds.
|Page 80 of 800||Search logiweb.eu|