Changeset 16808 for trunk


Ignore:
Timestamp:
Jan 3, 2017, 12:49:43 AM (3 years ago)
Author:
rme
Message:

When doing loop destructuring, if there are more variables in the variables
list than there are values in values list, give remaining variables the
value of NIL.

This behavior is described in 6.1.1.7 of the spec. Closes ticket:1400.

This code an adaptation of code from SBCL that fixes the same issue.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/library/loop.lisp

    r16685 r16808  
    924924    (t (cons (subst-gensyms-for-nil (car tree))
    925925             (subst-gensyms-for-nil (cdr tree))))))
    926  
     926
     927(defmacro loop-destructuring-bind (lambda-list args-list &body body)
     928  (let ((*ignores* ()))
     929    (declare (special *ignores*))
     930    (let ((dl (subst-gensyms-for-nil lambda-list)))
     931      `(destructuring-bind (&optional ,@dl) ,args-list
     932         (declare (ignore ,@*ignores*))
     933         ,@body))))
     934
    927935(defun loop-build-destructuring-bindings (crocks forms)
    928936  (if crocks
    929       (let ((*ignores* ()))
    930         (declare (special *ignores*))
    931         `((destructuring-bind ,(subst-gensyms-for-nil (car crocks))
    932               ,(cadr crocks)
    933             (declare (ignore ,@*ignores*))
    934             ,@(loop-build-destructuring-bindings (cddr crocks) forms))))
     937      `((loop-destructuring-bind ,(car crocks) ,(cadr crocks)
     938        ,@(loop-build-destructuring-bindings (cddr crocks) forms)))
    935939      forms))
    936940
Note: See TracChangeset for help on using the changeset viewer.