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

Re: [Scheme-reports] Legacy caar to cddddr

 | Date: Mon, 24 Oct 2011 23:08:22 +0900
 | From: Alex Shinn <alexshinn@x>
 | On Mon, Oct 24, 2011 at 7:47 AM, Aubrey Jaffer <agj@x> wrote:
 | ...
 | The actual examples given in this thread so far only
 | include up to N=2, M=2, so we can only conclude that
 | the exception may in fact be necessary.
 | > How does destructuring work with mutation?  Does assigning to a
 | > bound variable alter the matched structure?
 | Wright's syntax does allow for mutation.

Cool!  URL for Wright's syntax?

Does it have a way to match without binding; or does one need to match
the whole structure even when interested in only one slot?

 | > Writing calls to SET-CAR! and SET-CDR! would require binding the pair
 | > containing the pointer to be changed.  That would destroy the
 | > obviousness of destructuring, but is easy to deal with using C*R: just
 | > remove the first character after the "C" (CR is the identity
 | > function).
 | I'd be interested to see real-world examples of (set-car! (c[ad]{3,}r x) y).

Here are uses matching "set-c[ad]r! (c[ad][ad][ad]"

	(if (and (pair? (cadar part))
		 (eq? 'lambda (caadar part))
		 (all-liftable? (cddr (cadar part)))
		 (liftable-nameocc? name (cddr (cadar part)))
		 (liftable-nameocc? name (cons 'begin passed))
		 (liftable-nameocc? name (cons 'begin (cddr term))))
	      (set! *local-liftnames*
		    (cons name *local-liftnames*))
	      (set-car! (cadar part) *liftable-lambda*)))

(define (tok:read-char dyn)
  (let ((c (read-char (cadr dyn))))
    (set-car! (cddddr dyn)
	      (if (or (eqv? c #\newline) (eof-object? c))
		  (+ 1 (car (cddddr dyn)))))

   (if (file-unlock! filename certificate)
       (set-car! (cdddr entry) #f)
       (slib:warn 'file-unlock! filename certificate 'failed))

 | My guess is these are examples of abusing lists as records.

When using association-lists it is natural to use a list for other
fields.  I don't consider that abuse.

Scheme-reports mailing list