4 ms·
I like Python, but how do they plan on teaching recursion with a language that doesn't optimize tail recursion? Oh, I see, just give them trivially small data
by postfuturist 15y ago
I like Python, but how do they plan on teaching recursion with a language that doesn't optimize tail recursion?
Oh, I see, just give them trivially small data sets: http://www-inst.eecs.berkeley.edu/~cs61a/sp12/labs/lab8/lab8.py http://www-inst.eecs.berkeley.edu/~cs61a/sp12/labs/lab8/lab8...
- dman 15y agoComing from lisp/scheme, this is my least favorite corner of Python.
- reledi 15y agoTeaching recursion isn't an issue as long as they explain why you should avoid tail recursion in Python.
- abecedarius 15y agoWhen I studied SICP I used XLisp under DOS (no tail recursion, 640k). OTOH Python's default recursion limit of 1000 is even more restrictive than that. The question I had is how are they going to code a metacircular interpreter? Apparently they make a Scheme interpreter instead.
- babarock 15y agoI'm currently reading SICP (the original one). Even though it's LISP instead of Python, the syllabus seems to be very implementation-agnostic. Tail recursion optimization is nice and comes in handy, but I don't think it matters much in the choice of a language to teach this course. Focus is naturally put on how a language looks on paper, more than how it executes on the machine. My 2c.
- tikhonj 15y agoI remember the text--and the old course--actually spent a good bit of time talking about proper tail calls and "iteration" vs "recursion". We talked about how the code behaves differently--e.g. space usage--and about how to identify the two types. Also, it's the Structure and Interpretation of Computer Programs; naturally, the first bit talks about how programs look (structure), but the second bit (mainly chapters 4 and 5, if I remember correctly) talks about exactly that: how to execute code on the machine. The last chapter, in fact, introduces a register-based language not unlike assembly.
- Jach 15y agoWhat's so hard about using a decorator? You still get the magic, it's just explicit. Just one possibility: http://code.activestate.com/recipes/474088/ http://code.activestate.com/recipes/474088/