Djangocon: Lispisms - Shai Berger

Tags: django, djangocon

(One of the summaries of a talk at the 2015 Djangocon EU conference).

Shai Berger is a member of the django core team. Lispisms? Those are concepts you could import from Lisp into python.

Lisp is invented in 1960, it is ancient. (All (your (code (is (full (of (parentheses))))))).. Many important concepts were invented in lisp. Garbage collection, recursion, dynamic typing. So: have we gotten everything that is useful out of Lisp? Or are there still gems hidden that we can use?

What about dynamically scoped variables? People have been asking for ages for the request object to be available globally and they always got the same answer: GLOBALS ARE EVIL. Their value changes unpredictably because everybody anywere can modify them. You can get some of the way with thread-locals.

But why is it evil? The fact is, it is very convenient. There are other places where we effectively do it, for instance we don’t need to pass the database connection object into every query…

Is it possible to use globals that behave themselves? Where every change is temporary, only passed down the call chain? A bit like a ‘with’ statement. This is the default in lisp. You can modify an existing variable and do things with it. Once the modification is out of scope, the old value is there again.

He showed a code example how it could be done. The code is at https://bitbucket.org/shaib/lispism .

He’s also experimenting with Lisp “restarts”: basically a way to influence a methode from the outside and tell it what to do if an exception occurs. He’s still working on it. It is being researched.

Photo from our 2014 cycling holiday
 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):