Changeset 11837


Ignore:
Timestamp:
Mar 21, 2009, 10:40:23 PM (10 years ago)
Author:
gz
Message:

Make loop-typed-init work on characters, but in any case, make loop-make-variable widen the type to include NIL if necessary

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/library/loop.lisp

    r11834 r11837  
    10631063
    10641064(defun loop-typed-init (data-type)
    1065   (when (and data-type (subtypep data-type 'number))
    1066     (if (or (subtypep data-type 'float) (subtypep data-type '(complex float)))
    1067         (coerce 0 data-type)
    1068         0)))
     1065  (when data-type
     1066    (if (subtypep data-type 'number)
     1067      (if (or (subtypep data-type 'float) (subtypep data-type '(complex float)))
     1068        (coerce 0 data-type)
     1069        0)
     1070      (if (subtypep data-type 'character)
     1071        #\Null
     1072        nil))))
    10691073
    10701074
     
    11581162         (unless (symbolp name)
    11591163           (loop-error "Bad variable ~S somewhere in LOOP." name))
     1164         (unless initialization (setq initialization (loop-typed-init dtype)))
     1165         (when (and iteration-variable-p
     1166                    (null initialization)
     1167                    dtype
     1168                    (not (typep nil dtype)))
     1169           (setq dtype `(or null ,dtype)))
    11601170         (loop-declare-variable name dtype)
    11611171         ;; We use ASSOC on this list to check for duplications (above),
    11621172         ;; so don't optimize out this list:
    1163          (push (list name (or initialization (loop-typed-init dtype)))
    1164                *loop-variables*))
     1173         (push (list name initialization) *loop-variables*))
    11651174        (initialization
    11661175         (cond (*loop-destructuring-hooks*
Note: See TracChangeset for help on using the changeset viewer.