Bob Tolbert ea5eba5916 Second part of the fix for yield inside a try-finally
As noted in #600, Python 3 allows a return inside a generator
method, that raises a StopIteration and passes the return value
inside the 'value' attr of the exception.

To allow this behaviour we simple set 'contains_yield' while compiling
'yield', thus allowing a return statement, but only for Python 3. Then
when compiling the try-except, we check for contains_yield to decide
whether there will be a return.

This allows code like:

(defn gen []
  (yield 3)
  "goodbye")

to compile in both Py2 and Py3. The return value is simply ignored in
Python 2.

hy2py in Python 2 gives:

def g():
    yield 3L
    u'goodbye'

while hy2py in Python 3 gives:

def g():
    yield 3
    return 'goodbye'

Turns out return in yield started in Python 3.3
2014-06-22 14:59:29 -06:00
2014-04-30 01:51:21 +03:00
2014-05-05 23:47:14 +05:30
2014-01-31 03:43:03 +02:00
2014-05-05 23:47:14 +05:30
2014-05-04 17:28:08 -04:00
2013-04-05 20:04:36 -04:00
2014-03-14 10:21:07 -04:00
2014-05-05 23:47:14 +05:30
2014-05-05 23:47:14 +05:30
2014-03-18 10:33:10 +02:00
2014-04-30 01:51:21 +03:00

Hy

Build Status Downloads version Coverage Status

Lisp and Python should love each other. Let's make it happen. Try it.

Hylarious Hacks

Django + Lisp

Python sh fun

Hy IRC bot

miniKanren in Hy

OK, so, why?

Well. Python is awesome. So awesome, that we have so many tools to alter the language in a core way, but we never use them.

Why?

Well, I wrote Hy to help people realize one thing about Python:

It's really awesome.

Oh, and lisps are neat.

(fan art from the one and only doctormo)

Project

Description
Hy fork
Readme 6.1 MiB
Languages
Python 50.7%
Hy 41.5%
reStructuredText 7.1%
Batchfile 0.4%
Makefile 0.3%