(cdr declaration))))
(entry (assq (car declaration) known-declarations)))
(if (and entry (syntax-match? (cadr entry) (cdr declaration)))
- ((cddr entry) declaration procedure)
+ ((cddr entry) procedure declaration biselector:cr)
(begin
(warn "Unknown declaration:" declaration)
declaration))))
+(define (map+ procedure items selector)
+ (map procedure
+ items
+ (biselect-list-elts items selector)))
+
(define known-declarations '())
(for-each (lambda (keyword)
(define-declaration keyword '(* IDENTIFIER)
- (lambda (declaration procedure)
+ (lambda (procedure declaration selector)
(cons (car declaration)
- (map procedure (cdr declaration))))))
+ (map+ procedure
+ (cdr declaration)
+ (biselect-cdr selector))))))
;; The names in USUAL-INTEGRATIONS are always global.
'(
- USUAL-INTEGRATIONS
- IGNORABLE
- IGNORE
- INTEGRATE
- INTEGRATE-OPERATOR
- INTEGRATE-SAFELY
- TYPE-CHECKS
- NO-TYPE-CHECKS
- RANGE-CHECKS
- NO-RANGE-CHECKS
+ usual-integrations
+ ignorable
+ ignore
+ integrate
+ integrate-operator
+ integrate-safely
+ type-checks
+ no-type-checks
+ range-checks
+ no-range-checks
))
-(define-declaration 'INTEGRATE-EXTERNAL
+(define-declaration 'integrate-external
`(* ,(lambda (object)
(or (string? object)
(pathname? object))))
- (lambda (declaration procedure)
- procedure
+ (lambda (procedure declaration selector)
+ (declare (ignore procedure selector))
declaration))
\f
(for-each
(lambda (keyword)
- (define-declaration keyword '(DATUM)
- (lambda (declaration procedure)
+ (define-declaration keyword '(datum)
+ (lambda (procedure declaration selector)
(list (car declaration)
- (let loop ((varset (cadr declaration)))
+ (let loop
+ ((varset (cadr declaration))
+ (selector (biselect-cadr selector)))
(cond ((syntax-match? '('set * identifier) varset)
(cons (car varset)
- (map procedure (cdr varset))))
+ (map+ procedure
+ (cdr varset)
+ (biselect-cdr selector))))
((syntax-match?* '(('union * datum)
('intersection * datum)
('difference datum datum))
varset)
(cons (car varset)
- (map loop (cdr varset))))
+ (map+ loop
+ (cdr varset)
+ (biselect-cdr selector))))
(else varset)))))))
- '(CONSTANT
- IGNORE-ASSIGNMENT-TRAPS
- IGNORE-REFERENCE-TRAPS
- PURE-FUNCTION
- SIDE-EFFECT-FREE
- USUAL-DEFINITION
- UUO-LINK))
+ '(constant
+ ignore-assignment-traps
+ ignore-reference-traps
+ pure-function
+ side-effect-free
+ usual-definition
+ uuo-link))
-(define-declaration 'REPLACE-OPERATOR '(* (IDENTIFIER * (DATUM DATUM)))
- (lambda (declaration procedure)
+(define-declaration 'replace-operator '(* (identifier * (datum datum)))
+ (lambda (procedure declaration selector)
(cons (car declaration)
- (map (lambda (rule)
- (cons (procedure (car rule))
- (map (lambda (clause)
- (list (car clause)
- (if (identifier? (cadr clause))
- (procedure (cadr clause))
- (cadr clause))))
- (cdr rule))))
- (cdr declaration)))))
+ (map+ (lambda (rule selector)
+ (cons (procedure (car rule) (biselect-car selector))
+ (map+ (lambda (clause selector)
+ (list (car clause)
+ (if (identifier? (cadr clause))
+ (procedure
+ (cadr clause)
+ (biselect-cadr selector))
+ (cadr clause))))
+ (cdr rule)
+ (biselect-cdr selector))))
+ (cdr declaration)
+ (biselect-cdr selector)))))
-(define-declaration 'REDUCE-OPERATOR '(* (IDENTIFIER DATUM * DATUM))
- (lambda (declaration procedure)
+(define-declaration 'reduce-operator '(* (identifier datum * datum))
+ (lambda (procedure declaration selector)
(cons (car declaration)
- (map (lambda (rule)
- (cons* (procedure (car rule))
- (if (identifier? (cadr rule))
- (procedure (cadr rule))
- (cadr rule))
- (map (lambda (clause)
- (if (syntax-match?*
- '(('null-value identifier datum)
- ('singleton identifier)
- ('wrapper identifier ? datum))
- clause)
- (cons* (car clause)
- (procedure (cadr clause))
- (cddr clause))
- clause))
- (cddr rule))))
- (cdr declaration)))))
\ No newline at end of file
+ (map+ (lambda (rule selector)
+ (cons* (procedure (car rule) (biselect-car selector))
+ (if (identifier? (cadr rule))
+ (procedure (cadr rule) (biselect-cadr selector))
+ (cadr rule))
+ (map+ (lambda (clause selector)
+ (if (syntax-match?*
+ '(('null-value identifier datum)
+ ('singleton identifier)
+ ('wrapper identifier ? datum))
+ clause)
+ (cons* (car clause)
+ (procedure (cadr clause)
+ (biselect-cadr selector))
+ (cddr clause))
+ clause))
+ (cddr rule)
+ (biselect-cddr selector))))
+ (cdr declaration)
+ (biselect-cdr selector)))))
\ No newline at end of file
(make-scode-open-block
(map substitution (scode-open-block-names expression))
(map (lambda (declaration)
- (map-decl-ids substitution declaration))
+ (map-decl-ids (lambda (id selector)
+ (declare (ignore selector))
+ (substitution id))
+ declaration))
(scode-open-block-declarations expression))
(alpha-substitute substitution (scode-open-block-actions expression)))))
(lambda (substitution expression)
(make-scode-declaration
(map (lambda (declaration)
- (map-decl-ids substitution declaration))
+ (map-decl-ids (lambda (id selector)
+ (declare (ignore selector))
+ (substitution id))
+ declaration))
(scode-declaration-text expression))
(alpha-substitute substitution
(scode-declaration-expression expression)))))
;;;; Binary selectors
(define (biselect-car selector)
- (let ((n (integer-length selector)))
- (+ (shift-left 1 n)
- (- selector (shift-left 1 (- n 1))))))
+ (biselect-append biselector:car selector))
(define (biselect-cdr selector)
- (+ (shift-left 1 (integer-length selector))
- selector))
+ (biselect-append biselector:cdr selector))
-(define (biselect-subform selector form)
- (if (> selector 1)
- (biselect-subform (quotient selector 2)
- (if (even? selector) (car form) (cdr form)))
- form))
+(define (biselect-cadr selector)
+ (biselect-append biselector:cadr selector))
+
+(define (biselect-cddr selector)
+ (biselect-append biselector:cddr selector))
;; Selector order is:
;; (= biselector:cadr (biselect-append biselector:car biselector:cdr))
biselector:cr
selectors))
+(define (biselect-list-elts list selector)
+ (if (pair? list)
+ (cons (biselect-car selector)
+ (biselect-list-elts (cdr list) (biselect-cdr selector)))
+ '()))
+
+(define (biselect-subform selector form)
+ (if (> selector 1)
+ (biselect-subform (quotient selector 2)
+ (if (even? selector) (car form) (cdr form)))
+ form))
+
(define-integrable biselector:cr #b00001)
(define-integrable biselector:car #b00010)
(define-integrable biselector:cdr #b00011)