source: project/release/4/matchable/trunk/matchable.scm @ 33291

Last change on this file since 33291 was 33291, checked in by Alex Shinn, 5 years ago

Syncing with upstream (path from TheLemonMan?).

File size: 975 bytes
Line 
1(module matchable *
2  (import scheme chicken)
3  (use lolevel)
4
5  ;; CHICKEN-specific glue
6
7  ;; slot-ref type obj n
8  ;; Returns the 'n'th field of the record 'obj'.
9  ;; 'n' might be a quoted symbol indicating a field name, we have to reject it
10  ;; since CHICKEN doesn't carry any information about the field names.
11  (define-syntax slot-ref
12    (syntax-rules ()
13      ((_ type obj n) (if (fixnum? n)
14                          (record-instance-slot obj n)
15                          (error "Accessing fields by name is not supported")))))
16
17  ;; slot-set! type obj n val
18  ;; Sets the value of the 'n'th field of the record 'obj' to 'val'.
19  (define-syntax slot-set!
20    (syntax-rules ()
21      ((_ type obj n val) (record-instance-slot-set! obj n val))))
22
23  ;; is-a? obj type
24  ;; Returns #t if 'obj' is a record with name 'type', #f otherwise.
25  (define-syntax is-a?
26    (syntax-rules ()
27      ((_ obj type) (record-instance? obj (quote type)))))
28
29  (include "match.scm")
30)
Note: See TracBrowser for help on using the repository browser.