remove progn in favor of do

This commit is contained in:
gilch 2015-08-09 01:00:51 -06:00
parent 66c1f38fcc
commit 33e0b4b3db
3 changed files with 6 additions and 7 deletions

View File

@ -289,10 +289,10 @@ conditional expression.
{1: 2, 3: 6, 9: 18, 5: 10, 7: 14} {1: 2, 3: 6, 9: 18, 5: 10, 7: 14}
do / progn do
---------- ----------
``do`` and `progn` are used to evaluate each of their arguments and return the ``do`` is used to evaluate each of its arguments and return the
last one. Return values from every other than the last argument are discarded. last one. Return values from every other than the last argument are discarded.
It can be used in ``lambda`` or ``list-comp`` to perform more complex logic as It can be used in ``lambda`` or ``list-comp`` to perform more complex logic as
shown in one of the following examples. shown in one of the following examples.

View File

@ -748,8 +748,7 @@ class HyASTCompiler(object):
return ret return ret
@builds("do") @builds("do")
@builds("progn") def compile_do(self, expression):
def compile_progn(self, expression):
expression.pop(0) expression.pop(0)
return self._compile_branch(expression) return self._compile_branch(expression)
@ -2371,7 +2370,7 @@ class HyASTCompiler(object):
@builds("eval_and_compile") @builds("eval_and_compile")
def compile_eval_and_compile(self, expression): def compile_eval_and_compile(self, expression):
expression[0] = HySymbol("progn") expression[0] = HySymbol("do")
hy.importer.hy_eval(expression, hy.importer.hy_eval(expression,
compile_time_ns(self.module_name), compile_time_ns(self.module_name),
self.module_name) self.module_name)
@ -2380,7 +2379,7 @@ class HyASTCompiler(object):
@builds("eval_when_compile") @builds("eval_when_compile")
def compile_eval_when_compile(self, expression): def compile_eval_when_compile(self, expression):
expression[0] = HySymbol("progn") expression[0] = HySymbol("do")
hy.importer.hy_eval(expression, hy.importer.hy_eval(expression,
compile_time_ns(self.module_name), compile_time_ns(self.module_name),
self.module_name) self.module_name)

View File

@ -7,7 +7,7 @@
{"methods" ~methods})]] {"methods" ~methods})]]
(with-decorator deco (with-decorator deco
(defn ~name ~params (defn ~name ~params
(progn ~@code))))) (do ~@code)))))
;; Some macro examples ;; Some macro examples
(defmacro route [name path params &rest code] (defmacro route [name path params &rest code]