Changeset 11852


Ignore:
Timestamp:
Mar 27, 2009, 10:39:27 PM (10 years ago)
Author:
gz
Message:

Handle complex loop variables

File:
1 edited

Legend:

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

    r11837 r11852  
    10641064(defun loop-typed-init (data-type)
    10651065  (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))))
     1066    (let ((val (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))))
     1073      (and val (typep val data-type) val))))
    10731074
    10741075
     
    11631164           (loop-error "Bad variable ~S somewhere in LOOP." name))
    11641165         (unless initialization (setq initialization (loop-typed-init dtype)))
    1165          (when (and iteration-variable-p
     1166         (when (and dtype
    11661167                    (null initialization)
    1167                     dtype
    11681168                    (not (typep nil dtype)))
    1169            (setq dtype `(or null ,dtype)))
     1169           (if (eq dtype 'complex)
     1170             (setq initialization 0 dtype 'number)
     1171             (when iteration-variable-p
     1172               (setq dtype `(or null ,dtype)))))
    11701173         (loop-declare-variable name dtype)
    11711174         ;; We use ASSOC on this list to check for duplications (above),
Note: See TracChangeset for help on using the changeset viewer.