From d5de7a480b8b067ea29295f5e6895a9e997711ff Mon Sep 17 00:00:00 2001 From: "Paul R. Tagliamonte" Date: Wed, 6 Mar 2013 22:13:14 -0500 Subject: [PATCH] returnable stuf --- hy/compiler.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 4270503..6d29418 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -172,18 +172,27 @@ class HyASTCompiler(object): @builds("for") def compile_for_expression(self, expression): + ret_status = self.returnable + self.returnable = False + expression.pop(0) # for name, iterable = expression.pop(0) target = self.compile_symbol(name) target.ctx = ast.Store() + # support stuff like: + # (for [x [1 2 3 4] + # y [a b c d]] ...) - return ast.For( - lineno=expression.start_line, - col_offset=expression.start_column, - target=target, - iter=self.compile(iterable), - body=self._mangle_branch([self.compile(x) for x in expression]), - orelse=[]) + ret = ast.For(lineno=expression.start_line, + col_offset=expression.start_column, + target=target, + iter=self.compile(iterable), + body=self._mangle_branch([ + self.compile(x) for x in expression]), + orelse=[]) + + self.returnable = ret_status + return ret @builds(HyList) def compile_list(self, expr):