This part is the one you might have been waiting for. It's time to add functions to our little language.
Functions are created with the lambda
form, which returns an instance of Closure
(find the class definition in diylisp/types.py
). The first few tests guide you to implement the lambda
form correctly.
The next tests concern calling functions. A function call happens when we evaluate a list in which the first element is a function closure.
Finally, we handle some situations where function calls are done incorrectly, and make sure we give appropriate errors.
This is probably the most difficult part of making the language, so don't worry if it takes a bit longer than the previous parts.
nosetests tests/test_5_adding_functions_to_the_mix.py --stop
Ready for the last part of the language? In part 6 we add a ways to work with lists.