Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read/write closures #48

Open
jnhnum1 opened this issue Jun 2, 2013 · 1 comment
Open

Read/write closures #48

jnhnum1 opened this issue Jun 2, 2013 · 1 comment

Comments

@jnhnum1
Copy link
Collaborator

jnhnum1 commented Jun 2, 2013

Generators can handle this particular example, but it would be nice if we could use this style of programming:

@closures
def makeCounter():
    x = 0
    def foo():
        x += 1
        return x
    return foo

which would be transformed into

def makeCounter():
     x = [0]
     def foo():
         x[0] += 1
         return x[0]
     return foo
@lihaoyi
Copy link
Owner

lihaoyi commented Jun 2, 2013

We would probably need basic static analysis (#44) in order to keep track of scoping and make sure it's the same variable we're assigning too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants