[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]"

scm/hobbit.scm:5722:
	(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))))
	    (begin
	      (set! *local-liftnames*
		    (cons name *local-liftnames*))
	      (set-car! (cadar part) *liftable-lambda*)))

slib/prec.scm:60:
(define (tok:read-char dyn)
  (let ((c (read-char (cadr dyn))))
    (set-car! (cddddr dyn)
	      (if (or (eqv? c #\newline) (eof-object? c))
		  0
		  (+ 1 (car (cddddr dyn)))))
    c))

slib/dbutil.scm:291:
   (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
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports