[iterate-devel] [Bug] Hashtable traversal code always put at the beginning
SYSTEM DESCRIPTION > Iterate version: latest from darcs repository and 1.4.3 Lisp implementation: SBCL 1.0.33 BUG DESCRIPTION> when using FOR..IN-HASHTABLE the code generated for hash-table traversing is always put at the beginning of generate code, with the result that the hash-table to be traversed must be in scope since the beginning of the ITER form. EXAMPLE > (macroexpand-1 '(iter:iter (iter:with table = (make-hash-table)) (iter:for (k v) in-hashtable table) (format t "~A ~A ~%" k v))) ==> (WITH-HASH-TABLE-ITERATOR (#:HASH-TABLE-ITERATOR-810 TABLE) ; <-- 'TABLE used before being bound (LET* ((TABLE (MAKE-HASH-TABLE)) (#:G811 NIL) (K NIL) (V NIL)) (BLOCK NIL (TAGBODY (PROGN) LOOP-TOP-NIL (PROGN (MULTIPLE-VALUE-SETQ (#:G811 K V) (#:HASH-TABLE-ITERATOR-810)) (IF (NOT #:G811) (GO LOOP-END-NIL)) (FORMAT T "~A ~A ~%" K V)) (PROGN) (GO LOOP-TOP-NIL) LOOP-END-NIL (PROGN)) NIL))) thank you, Andrea
Hi, so I played with this a bit and attached a patch to fix it by moving the wrapping with WRAP-FORM/LOOP-BODY-WRAPPERS one level down inside the variable declarations. Two test cases are included (one for IN-HASHTABLE, the other for IN-PACKAGE, which shares the behaviour). Since no other parts of the code need the current behaviour of WRAP-FORM I just changed it instead of introducing another wrapper list like LOOP-BODY-INNER-WRAPPERS or so ... Cheers, Olof -- The world is burning. Run.
participants (2)
-
Andrea Taverna
-
Olof-Joachim Frahm