![]() |
|
last edited 3 years ago by test1 |
1 2 3 4 5 | ||
Editor: test1
Time: 2019/07/17 17:17:25 GMT+0 |
||
Note: |
added:
To debug Boot code add diagnostic printouts using SAY, like
\begin{boot}
print_bar(x) ==
SAY(["print_bar", x])
\end{boot}
\begin{axiom}
)boot print_bar(123)
\end{axiom}
Note: Unlike other printing functions 'SAY' prints to terminal even if normal output is redirected to
a file. So it is useful for debugging for example Spad compiler, where normal output goes to
file.
One can also add breakpoints using 'BREAK()'. When executed 'BREAK()' passes control to Lisp
debugger and one can for example find out which code called given place. 'BREAK()' is used
in FriCAS sources to indicate conditions that should be always true, but we want visible report
if they fail.
Boot (more precisely newer dialect called Shoe) is used internally in FriCAS for some of the interpreter and compiler code. Here is a detailed description of the Boot Language
This is a simple example of Boot programming.
Define a function.
pairBoot(a,b) == a>b => [-b, -a] [a, b]
9211484592716052519-25px001.clisp PRODUCED ; compiling file "/var/aw/var/LatexWiki/9211484592716052519-25px001.clisp" (written 04 APR 2022 02:53:54 PM):
; /var/aw/var/LatexWiki/9211484592716052519-25px001.fasl written ; compilation finished in 0:00:00.044
Now call it.
pairBoot(1,4)$Lisp
![]() | (1) |
map(integer,destruct(pairBoot(3, 2)$Lisp))
![]() | (2) |
That's my first Boot function!
You can now write for example:
foobar(x,y) == x + y
7491012761112044243-25px003.clisp PRODUCED ; compiling file "/var/aw/var/LatexWiki/7491012761112044243-25px003.clisp" (written 04 APR 2022 02:53:54 PM):
; /var/aw/var/LatexWiki/7491012761112044243-25px003.fasl written ; compilation finished in 0:00:00.011
And call it with
integer(foobar(2,3)$Lisp)
![]() | (3) |
In FriCAS (from revision 1049 on) the simplest way to compile and load boot code is to write it into a file and then call something like:
)read FILE.boot
To debug Boot code add diagnostic printouts using SAY, like
print_bar(x) == SAY(["print_bar",x])
6147864484223767607-25px005.clisp PRODUCED ; compiling file "/var/aw/var/LatexWiki/6147864484223767607-25px005.clisp" (written 04 APR 2022 02:53:54 PM):
; /var/aw/var/LatexWiki/6147864484223767607-25px005.fasl written ; compilation finished in 0:00:00.001
)boot print_bar(123)
(EVAL-WHEN (EVAL LOAD) (PROG () (RETURN (|print_bar| 123)))) (print_bar 123) Value = NIL
Note: Unlike other printing functions SAY
prints to terminal even if normal output is redirected to
a file. So it is useful for debugging for example Spad compiler, where normal output goes to
file.
One can also add breakpoints using BREAK()
. When executed BREAK()
passes control to Lisp
debugger and one can for example find out which code called given place. BREAK()
is used
in FriCAS sources to indicate conditions that should be always true, but we want visible report
if they fail.