~swisschili/bluejay

ref: 6d02af472f6ce87ea50ff24aa77f88928dbf31bc bluejay/src/lisp/test.lisp -rw-r--r-- 476 bytes
6d02af47swissChili Add detailed error reporting, remove panics 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(defun add-two (a)
  (+ a 2))

(defun calls-gc (whatever)
  (print whatever)
  (gc))

(defmacro weird-identity (a)
  a)

(defmacro weird-const (a b)
  a)

(defun main ()
  (let1 (a (add-two 3))
    (print "a is")
    (print (weird-identity a))
    (print (weird-const a 4)))

  ; These allocations should be freed
  (list 12 34 56)
  (list "a" "b" "c" "d")
  
  ; But these should not
  (let1 (unused-but-bound (cons 5 6))
    (let1 (val '(a b c d e))
      (calls-gc val))))