Python 3 isn't really good. It's not really bad, either. There's really not that many magic bullets (other than proper functional programming, maybe, which isn't about to happen in Python). People are leaving Python for Go because people have always left Python for fast compiled languages. Google ditched Python for C++ and Java. Java! I've seen a lot of projects get re-written in Java from Python, but no-one worried…
other than proper functional programming, maybe, which isn't about to happen in Python If we could just have tail call optimization, I think we could make the rest work (well, maybe better lambdas, too).
Manually thunk/trampoline it?
class trampoline(object):
def __init__(self, fn):
self.fn = fn
def __call__(self, *args, **kwargs):
ret = self.fn(*args, **kwargs)
while isinstance(ret, thunk):
ret = ret()
return ret
class thunk(object):
def __init__(self, fn, *args, **kwargs):
self.__dict__.update(fn=fn, args=args, kwargs=kwargs)
def __call__(self):
if isinstance(self.fn, trampoline):
return self.fn.fn(*self.args, **self.kwargs)
else:
return self.fn(*self.args, **self.kwargs)
@trampoline
def fact(n, accum=1):
if n
You only have to write thunk/trampoline utility once, and it is similar to how we do it in clojure.