How to resolve the algorithm Metaprogramming step by step in the TXR programming language
How to resolve the algorithm Metaprogramming step by step in the TXR programming language
Table of Contents
Problem Statement
Name and briefly demonstrate any support your language has for metaprogramming. Your demonstration may take the form of cross-references to other tasks on Rosetta Code. When possible, provide links to relevant documentation. For the purposes of this task, "support for metaprogramming" means any way the user can effectively modify the language's syntax that's built into the language (like Lisp macros) or that's conventionally used with the language (like the C preprocessor). Such facilities need not be very powerful: even user-defined infix operators count. On the other hand, in general, neither operator overloading nor eval count. The task author acknowledges that what qualifies as metaprogramming is largely a judgment call.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Metaprogramming step by step in the TXR programming language
Source code in the txr programming language
(defmacro whil ((condition : result) . body)
(let ((cblk (gensym "cnt-blk-"))
(bblk (gensym "brk-blk-")))
^(macrolet ((break (value) ^(return-from ,',bblk ,value)))
(symacrolet ((break (return-from ,bblk))
(continue (return-from ,cblk)))
(block ,bblk
(for () (,condition ,result) ()
(block ,cblk ,*body)))))))
(let ((i 0))
(whil ((< i 100))
(if (< (inc i) 20)
continue)
(if (> i 30)
break)
(prinl i)))
(prinl
(sys:expand
'(whil ((< i 100))
(if (< (inc i) 20)
continue)
(if (> i 30)
break)
(prinl i))))
You may also check:How to resolve the algorithm Variables step by step in the Scala programming language
You may also check:How to resolve the algorithm Loops/Continue step by step in the Agena programming language
You may also check:How to resolve the algorithm Variable-length quantity step by step in the BASIC programming language
You may also check:How to resolve the algorithm Function definition step by step in the Aime programming language
You may also check:How to resolve the algorithm Execute Brain step by step in the Mathematica / Wolfram Language programming language