OSDN Git Service

Rename pushback() to concat().
[joypy/Thun.git] / joy / utils / stack.py
index 6bcc5b4..0a0506f 100644 (file)
@@ -142,7 +142,7 @@ _s = lambda s: (
   )
 
 
-def pushback(quote, expression):
+def concat(quote, expression):
   '''Concatinate quote onto expression.
 
   In joy [1 2] [3 4] would become [1 2 3 4].
@@ -155,7 +155,8 @@ def pushback(quote, expression):
   # This is the fastest implementation, but will trigger
   # RuntimeError: maximum recursion depth exceeded
   # on quotes longer than sys.getrecursionlimit().
-  return (quote[0], pushback(quote[1], expression)) if quote else expression
+
+##  return (quote[0], concat(quote[1], expression)) if quote else expression
 
   # Original implementation.
 
@@ -164,13 +165,13 @@ def pushback(quote, expression):
   # In-lining is slightly faster (and won't break the
   # recursion limit on long quotes.)
 
-##  temp = []
-##  while quote:
-##    item, quote = quote
-##    temp.append(item)
-##  for item in reversed(temp):
-##    expression = item, expression
-##  return expression
+  temp = []
+  while quote:
+    item, quote = quote
+    temp.append(item)
+  for item in reversed(temp):
+    expression = item, expression
+  return expression