No more unquotes to instantiate templates. Also no need to pass quoted substitution lists, just use them as regular lisp macros.
70 lines
1.6 KiB
Scheme
70 lines
1.6 KiB
Scheme
(include stdlib.h)
|
|
(include stddef.h)
|
|
(include stdbool.h)
|
|
(include stdio.h)
|
|
|
|
(chicken-import srfi-1 brev-separate) ; list routines, e.g. fold
|
|
|
|
(chicken-load "list.seh")
|
|
|
|
(chicken-define (imports-test a b c)
|
|
(fold + 0 (list 1 2 3 a b c)))
|
|
|
|
(struct foo
|
|
((float a-field)
|
|
(int b)
|
|
((const char *) c)
|
|
((fn bool ((bool val))) not)))
|
|
|
|
(var foo f #((= .a-field 1.2)))
|
|
|
|
(list-T int)
|
|
(make-list-T int)
|
|
(add-value-list-T int)
|
|
(length-list-T int)
|
|
(is-empty-list-T int)
|
|
|
|
(extern fn void puk ((int a) (float b)))
|
|
(fn int bar () ,(imports-test 10 20 30))
|
|
(pub fn void baz () true)
|
|
|
|
(extern var int i)
|
|
(var int j)
|
|
(pub var int k)
|
|
|
|
(pub fn int main ()
|
|
(var (* list-int) l (make-list-int))
|
|
(printf "Size of the list: %zu\n" (length-list-int l))
|
|
(add-value-list-int l 3)
|
|
(add-value-list-int l 4)
|
|
(printf "Size of the list: %zu\n" (length-list-int l))
|
|
(list-for-each l v
|
|
(printf "%d " v))
|
|
(printf "\n")
|
|
(printf "%zu\n" l->next)
|
|
0)
|
|
|
|
(pub fn segs-renderer* create-renderer ())
|
|
(pub fn void clear-command-buffer ((segs-renderer *r)))
|
|
(pub fn void add-render-command ((segs-renderer *r) ((fn void ()) command)))
|
|
(pub fn void commit-command-buffer ((segs-renderer *r)))
|
|
|
|
(template (list-T ?T)
|
|
(struct list-?T
|
|
((?T value)
|
|
((* list-?T) next))))
|
|
|
|
(template (list-for-each type list-var elt-var body)
|
|
(var type elt-var (-> list-var value))
|
|
(while (!= (-> list-var next) NULL)
|
|
body
|
|
(= list-var (-> list-var next))
|
|
(= elt-var (-> list-var value))))
|
|
|
|
; ... somewhere later
|
|
(list-T int)
|
|
|
|
(pub fn void print-list (((const list-int) *l))
|
|
(list-for-each int l v (printf "%d " v))
|
|
(printf "\n"))
|