"Fossies" - the Fresh Open Source Software Archive

Member "txr-217/tests/011/macros-2.txr" (10 Jun 2019, 989 Bytes) of package /linux/misc/txr-217.tar.bz2:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 @(do
    2    (set *gensym-counter* 0)
    3 
    4    (macro-time
    5      (defmacro whilst ((condition : result) . body)
    6        (let ((cblk (gensym "cnt-blk-"))
    7              (bblk (gensym "brk-blk-")))
    8          ^(macrolet ((break (value) ^(return-from ,',bblk ,value)))
    9             (symacrolet ((break (return-from ,bblk))
   10                          (continue (return-from ,cblk)))
   11               (block ,bblk
   12                 (for () (,condition ,result) ()
   13                   (block ,cblk ,*body))))))))
   14 
   15    (let ((i 0))
   16      (whilst ((< i 100))
   17        (if (< (inc i) 20)
   18          continue)
   19        (if (> i 30)
   20          break)
   21        (prinl i)))
   22 
   23    (prinl
   24      (ignwarn
   25        (expand
   26          '(whilst ((< i 100))
   27             (if (< (inc i) 20)
   28               continue)
   29             (if (> i 30)
   30               break)
   31             (prinl i)))))
   32 
   33    (let ((i 0))
   34      (whilst ((< i 5))
   35        (inc i)
   36        (labels ((whilst () 'whilst))
   37          (let ((break 'break))
   38            (prinl (list (whilst) break)))))))