[plt-scheme] Re: Should PLT Scheme have two R6RS namespaces?

From: detmammut at googlemail.com (detmammut at googlemail.com)
Date: Mon Mar 23 18:15:37 EDT 2009

On Mar 23, 5:50 pm, Matthias Felleisen <matth... at ccs.neu.edu> wrote:
> Units sounds like the exact proper design choice here.

Is there a way to specify that a signature conatains a certain syntax
definitions? The problem I can see is with lambda (eg. the following
code from srfi/1/search.ss):

(define (span pred lis)
  (check-arg procedure? pred 'span)
  (let recur ((lis lis))
    (if (null-list? lis) (values '() '())
        (let ((x (car lis)))
          (if (pred x)
            (let-values ([(prefix suffix) (recur (cdr lis))])
              (values (cons x prefix) suffix))
            (values '() lis))))))


(define (any pred lis1 . lists)
  (check-arg procedure? pred 'any)
  (if (pair? lists)
    ;; N-ary case
    (let-values ([(heads tails) (%cars+cdrs (cons lis1 lists))])
      (and (pair? heads)
           (let lp ((heads heads) (tails tails))
             (let-values ([(next-heads next-tails) (%cars+cdrs
               (if (pair? next-heads)
                 (or (apply pred heads) (lp next-heads next-tails))
                 (apply pred heads)))))) ; Last PRED app is tail call.
    ;; Fast path
    (and (not (null-list? lis1))
         (let lp ((head (car lis1)) (tail (cdr lis1)))
           (if (null-list? tail)
             (pred head)                ; Last PRED app is tail call.
             (or (pred head) (lp (car tail) (cdr tail))))))))

note that cons is used to create a return value for the target
language in the first procedure, and to cons rest-lists in the host
language in the second procedure.

Posted on the users mailing list.