(library (types)
(export string-sub *eof* non-list?
- string->keyword _keyword?
+ string->keyword _keyword? _string?
nil _nil? list->hash-map
- cond-true?
+ cond-true? make-anonymous-func
make-atom atom? atom-val atom-val-set!
make-callable callable? callable-is_macro
callable-is_macro-set! callable-closure
- is-func? is-macro? make-func callable-apply
+ is-func is-func? is-macro is-macro? make-func callable-apply
callable-unbox-set! callable-unbox
callable-meta-info hash-table-clone
box? box unbox)
- (import (guile) (rnrs) (ice-9 regex) (ice-9 session)))
+ (import (guile) (only (rnrs) define-record-type) (ice-9 regex) (ice-9 session)))
(define (non-list? x) (not (list? x)))
(string-append "\u029e" str))
(define (_keyword? k)
- (and (string? k) (if (string-match "^\u029e" k) #t #f)))
+ (and (string? k)
+ (> (string-length k) 0)
+ (char=? #\1236 (string-ref k 0))))
+
+(define (_string? s)
+ (and (string? s) (not (_keyword? s))))
(define-record-type mal-nil)
closure))
(define (make-func closure) (make-callable nil #t #f closure))
+(define (make-anonymous-func closure) (make-callable nil #f #f closure))
(define (callable-apply c arglst)
(apply (callable-closure c) (if (callable-unbox c) (map unbox arglst) arglst)))
(eq? (callable-is_macro c) b)
c))
-(define (is-func? c) (callable-check c #f))
-(define (is-macro? c) (callable-check c #t))
+(define (is-func c) (callable-check c #f))
+(define (is-func? c) (and (is-func c) #t))
+(define (is-macro c) (callable-check c #t))
+(define (is-macro? c) (and (is-macro c) #t))
(define (hash-table-clone ht)
(list->hash-map (hash-fold (lambda (k v p) (cons k (cons v p))) '() ht)))