chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] base64 update and hygienic matching


From: Alex Shinn
Subject: Re: [Chicken-users] base64 update and hygienic matching
Date: Tue, 5 Dec 2006 11:09:00 +0900

On 12/5/06, felix winkelmann <address@hidden> wrote:

* Alex Shinn has written a hygienic pattern matching package, mostly
  compatible to Chicken's default matching stuff

You need this whenever you want to mix MATCH with hygienic
macros, or things will break quickly.

Just replace

(use match)

with

(use matchable)

Note the loopy-loop egg now supports implicit pattern matching
on variables, so that, for example

(define (assq-ref ls k)
 (let loop ((ls ls))
   (if (null? ls)
       #f
       (let ((key (car ls))
             (val (cdr ls)))
         (if (eq? key k)
             val
             (loop (cdr ls)))))))

could be more clearly written as

(define (assq-ref ls k)
 (loop lp (((key . val) <- in-list ls))
   => #f
   (if (eq? key k)
       val
       (lp))))

removing all CAR's and CDR's from the body.

This pattern matching is just as fast as manual
destructuring, and incurs zero overhead when
you don't use any matching in your loops.

--
Alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]