Am 22.10.2011 19:55, schrieb John Cowan: > Andre van Tonder scripsit: > >> (define-syntax do >> (er-transformer >> (lambda (exp r c) >> (or (and (pair? (cdr exp)) >> (pair? (cddr exp))) >> (syntax-error)) >> (let ((specs (cadr exp)) >> (end (caddr exp)) >> (body (cdddr exp)) >> (loop (syntax loop))) > > It's not obvious why this is better than pattern-matching, though.
Also, a destructuring let form would be a much better solution. For instance, in Clojure you can write something like: (let [[_ specs end & body] exp] ...) We could have something similar in WG2: (let (((_ specs end . body) exp)) ...) Even better, we could also have an "if-let" form whose execution path depends on whether the destructuring is possible: (if-let (((_ specs end . body) exp)) ... (syntax-error)) Such destructuring forms would remove most reasons for having cadr etc. in the standard. Regards, Denis _______________________________________________ Scheme-reports mailing list [email protected] http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
