aboutsummaryrefslogtreecommitdiff
path: root/examples/working/macro.ey
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2012-12-10 14:30:07 +0100
committerDrahflow <drahflow@gmx.de>2012-12-10 14:30:07 +0100
commit26c5b2be3918e7e27f9ae0616f3a3a629190b19c (patch)
tree9fe1e3b4631e460acbc5d92c62dab176cfdca5a5 /examples/working/macro.ey
parent9de23daca3f223643eb4d0f92636d72d0f5c9364 (diff)
Quicksort
Diffstat (limited to 'examples/working/macro.ey')
-rw-r--r--examples/working/macro.ey51
1 files changed, 51 insertions, 0 deletions
diff --git a/examples/working/macro.ey b/examples/working/macro.ey
new file mode 100644
index 0000000..fdaf0cf
--- /dev/null
+++ b/examples/working/macro.ey
@@ -0,0 +1,51 @@
+# an alternative to }, moving the top stack element
+# into closure storage and pushing it back before
+# executing the block
+
+{ "}" | *
+ { /f deff /x defv
+ { x f }
+ } quoted { } { * } ? *
+} "}0" defq
+
+5 { { dump }0 } * /dumpfive deff
+5 { dump }0 /dumpfivetwo deff
+
+7 dumpfive -
+7 dumpfivetwo -
+
+
+# import members of other objects into local scope
+
+{
+ "_" | "-021" | ".|" | "-01" | |deff
+} /usef defq
+
+
+# codewalker
+
+{ "lol" dump } /lol deff
+
+{
+ 1 /cont defv
+
+ { cont } { 0 {
+ exe /walkelem deff
+ { sys .out .writestr } /out deff
+
+ _ { { " " out } rep }0 /indent deff
+ { 2 add walkelem }0 /walk deff
+
+ _ code [ {
+ indent [ "\"" -102 "\"\n" ] |out each
+ } {
+ indent _ sym _ out
+ "{" streq { 0 =cont |lol } { - } ? *
+ "\n" out
+ } {
+ blk |walk each
+ } ] * *
+ } * } loop
+} /codewalk defq
+
+{ f "t" g h { a b { c d } e } codewalk } *