(defvar *loop-after-epilogue*)
;;; the "culprit" responsible for supplying a final value from the
-;;; loop. This is so LOOP-EMIT-FINAL-VALUE can moan about multiple
-;;; return values being supplied.
+;;; loop. This is so LOOP-DISALLOW-AGGREGATE-BOOLEANS can moan about
+;;; disallowed anonymous collections.
(defvar *loop-final-value-culprit*)
;;; If this is true, we are in some branch of a conditional. Some
(defun loop-emit-final-value (&optional (form nil form-supplied-p))
(when form-supplied-p
(push (loop-construct-return form) *loop-after-epilogue*))
- (when *loop-final-value-culprit*
- (loop-warn "The LOOP clause is providing a value for the iteration;~@
- however, one was already established by a ~S clause."
- *loop-final-value-culprit*))
(setq *loop-final-value-culprit* (car *loop-source-context*)))
(defun loop-disallow-conditional (&optional kwd)
\f
;;;; loop types
-(defun loop-typed-init (data-type)
+(defun loop-typed-init (data-type &optional step-var-p)
(when (and data-type (sb!xc:subtypep data-type 'number))
(if (or (sb!xc:subtypep data-type 'float)
(sb!xc:subtypep data-type '(complex float)))
- (coerce 0 data-type)
- 0)))
+ (coerce (if step-var-p 1 0) data-type)
+ (if step-var-p 1 0))))
(defun loop-optional-type (&optional variable)
;; No variable specified implies that no destructuring is permissible.
((null entry) (return nil))
((assoc name (caar entry) :test #'eq) (return t)))))
-(defun loop-make-var (name initialization dtype &optional iteration-var-p)
+(defun loop-make-var (name initialization dtype &optional iteration-var-p step-var-p)
(cond ((null name)
(setq name (gensym "LOOP-IGNORE-"))
(push (list name initialization) *loop-vars*)
name)))
(unless (symbolp name)
(loop-error "bad variable ~S somewhere in LOOP" name))
- (loop-declare-var name dtype)
+ (loop-declare-var name dtype step-var-p)
;; We use ASSOC on this list to check for duplications (above),
;; so don't optimize out this list:
- (push (list name (or initialization (loop-typed-init dtype)))
+ (push (list name (or initialization (loop-typed-init dtype step-var-p)))
*loop-vars*))
(initialization
(let ((newvar (gensym "LOOP-DESTRUCTURE-")))
(defun loop-make-iteration-var (name initialization dtype)
(loop-make-var name initialization dtype t))
-(defun loop-declare-var (name dtype)
+(defun loop-declare-var (name dtype &optional step-var-p)
(cond ((or (null name) (null dtype) (eq dtype t)) nil)
((symbolp name)
(unless (sb!xc:subtypep t dtype)
- (let ((dtype (let ((init (loop-typed-init dtype)))
+ (let ((dtype (let ((init (loop-typed-init dtype step-var-p)))
(if (sb!xc:typep init dtype)
dtype
`(or (member ,init) ,dtype)))))
(limit-value nil)
)
(flet ((assert-index-for-arithmetic (index)
- (unless (atom indexv)
+ (unless (atom index)
(loop-error "Arithmetic index must be an atom."))))
(when variable (loop-make-iteration-var variable nil variable-type))
(do ((l prep-phrases (cdr l)) (prep) (form) (odir)) ((null l))
(unless stepby-constantp
(loop-make-var (setq stepby (gensym "LOOP-STEP-BY-"))
form
- `(and ,indexv-type (real (0))))))
+ `(and ,indexv-type (real (0)))
+ nil t)))
(t (loop-error
"~S invalid preposition in sequencing or sequence path;~@
maybe invalid prepositions were specified in iteration path descriptor?"