Guile scheme tuto
Table of Contents
This file contains some examples of scheme prog.
Hello world
Debugging emacs, geiser-guile and scheme
With "output" added after #+begin_src :results, the result (after #+RESULTS) is ": Geiser Interpreter produced no output" which is not the expected result.
It seems that the temporary result buffer close to soon. To avoid this, it's necessary to modify "ob-scheme.el" as follow:
- locate the file (mine were on "/usr/local/share/emacs/29.0.50/lisp/org")
- replace "geiser-eval-region" with "geiser-eval-region/wait" :
;;(let ((ret (geiser-eval-region (point-min) (point-max)))) (let ((ret (geiser-eval-region/wait (point-min) (point-max))))
#+begin_src scheme :exports both :results output
(display "Hello world 2!\n") (+ 1 2) (define test (lambda (v) (* 2 v)) (test '4)
Geiser Interpreter produced no output
#+end_src
- After
:resultsplace "value" to catch the returned value (with "output" the evaluation of the code returns nothing or errors when it's the case)
(+ 1 2)
3
- With "output" after
:resultone can catch error from geiser - And if there is an error is due to ' instead " (see next example)
(define test (lambda (v) v)) (test 'Bad Test with error)
ice-9/boot-9.scm:1685:16: In procedure raise-exception: Unbound variable: Test Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]>
- But you need to add "value" after
:resultto catch the result of the code
(define test (lambda (v) v)) (test "Test avec un meilleur fonctionnement")
Test avec un meilleur fonctionnement
Some complemenary and elementary tests
(define x 10) (if (> x 0) (begin (display x) (newline)))
10