[plt-scheme] Does anyone use `set!' and `get!' patterns?

From: hendrik at topoi.pooq.com (hendrik at topoi.pooq.com)
Date: Wed Mar 12 16:21:58 EDT 2008

On Tue, Mar 11, 2008 at 09:59:13AM -0400, Sam TH wrote:
> On Tue, Mar 11, 2008 at 9:36 AM, Eli Barzilay <eli at barzilay.org> wrote:
> > This is probably the original motivation for this feature.  For
> >  example, with the generic setters in Swindle, you get
> >
> >   (inc! (cadddr x))
> >
> >  to expand to
> >
> >   (set-cadddr! x (+ (cadddr x) 1))
> >
> >  and my guess is that with the match setters, it would be like doing
> >
> >   (let ([x (cdddr x)]) (set-car! x (+ (car x) 1)))
> 
> Right.  Something like:
> 
> (match x
>   [(list-rest c _ _ (set! x!)) (x! (+ c 1))])

That looks useful!  If, that is, the objects in question are mutable.

-- hendrik

> 
> -- 
> sam th
> samth at ccs.neu.edu
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.