Re: Only in Lisp
Posted: Fri May 14, 2010 6:52 pm
Actually, you got the wrong problem. Creating the closure, ok, that is easy and has nothing to do with macros. The macros which are created are macros that make it possible to store a function into a file. In my particular case, I would have a program that generated code (using lists) that would be evaluated (compiled) and produce various functions. Those functions would be lost around objects (class objects), many would be substituted by other functions, ans so on. Then, at some point, I would like to be able to save everything into a file and close the application in such a way that I could continue computation later when opening the program again.Gerenuk wrote:I'd say there is only one straightforward way.gugamilare wrote: Now, there are a couple of ways you would do it in, e.g., Python:
There my macros come into place. There is already many libraries that are able to store any kind of objects into files. I chose one that was extensible, cl-store, and extended it to allow storage of functions. How, you ask? Creating macros that would remember the code of the functions and variables in their creation, associating them with their code (in a hash-table) and free variables.
A MetaObject Protocol and... macrosGerenuk wrote: That's absolutely true - before iterators/generators were introduced there was a really useful part missing. But OK: can you think of a feature that isn't implemented in Python yet?
Iterators and generators are, but beyond that there isn't much special. So is anything missing in Python?

I think you are viewing this the wrong way. Of course Python has every general-purpose tools available today. But, in Lisp, you can create not-so-general tools, specific for your problems. It is a common concept that libraries in Lisp are actually DSLs created for their specific purpose. So it is hard to say which tools Python does not have, except the meta-tools that allow you to create your own tools as you need them. Whether each specific problems need their own tool or not, that varies with the problems themselves.
Try reading ANSI Common Lisp from Paul Graham, it has a neat explanation about what is Lisp all about, The Art of MetaObject Protocol, that explains what is MOP and why it is so useful, or Practical Common Lisp, which is a gentle and yet deep introduction into Common Lisp.