Skip to content

Instantly share code, notes, and snippets.

@letoh
Created May 12, 2012 07:56
Show Gist options
  • Save letoh/2665112 to your computer and use it in GitHub Desktop.
Save letoh/2665112 to your computer and use it in GitHub Desktop.
from dsl.scheme import *
(_define . foo
((1, 2, 3)))
(_define . bar
(lambda x: x + 4))
(_display (1, 3))
(_cons. a (_cons. b (_cons. c ())))
@letoh
Copy link
Author

letoh commented May 12, 2012

class Display(object):
def call(s, *x):
print x
return x

display_ = Display()

class Define(object):
def init(s, sym = None):
s._sym = sym

def __getattr__(s, name):
    s._sym = name
    return s

def __call__(s, *args):
    s.__bind__(s._sym, *args)
    return s

def __bind__(s, sym, body):
    globals()[sym] = body

define_ = Define()

class Cons(object):
def getattr(s, name):
return s

def __call__(s, arg = None):
    return s

cons_ = Cons()

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