Archive for the LISP Category

User defined macros

Posted in LISP, programming on December 21, 2008 by bbarrett

I have just finished hacking in user defined macros. For the moment they look like they will be up to any use I want to make of them at the moment. They are fairly simple, they are syntactically similar to functions. They must return a list. This then replaces the invoking code during compilation.
Continue reading


Back from beyond the grave

Posted in LISP, programming on December 15, 2008 by bbarrett


Long time, no post. I don’t really have an excuse for that. Just generally being busy and not having a huge amount of time for personal projects. Hopefully I will get a little time over christmas.

I’ve done a little here and there, but nothing that seemed worthy of an update.

Today, I have started back into my Lisp interpreter. I fixed a load of minor bugs. I’ve added small amounts of other functionality. For example, I have added a type, similar to Lua’s lightuserdata. To test it, I made a set of functions for file manipulation. That, combined with the eval function I already had allows me to define (purely in Lisp) functions for including files.
Continue reading

I am an idiot.

Posted in LISP, nonsense, programming with tags , , on September 11, 2008 by bbarrett

I have just figured out where I am going wrong. All my variables are stored on the LISP stack, which is a std::vector<Cell> instance, (Cell is the variable type). Some of these Cells themselves contain Standard C++ Library objects (lists use std::list<>, functions are std::vector<Instruction>, strings are std::strings), and references to those objects are stored on the C++ stack during operation.

A few functions deep, when stuff keeps being added to the stack, it eventually will reallocate and… boom, all my iterators and references die a horrible death. Took quite a while to figure out that this was going on, I was preoccupied with assuming there was an issue with the Cell’s implementation of the Rule Of Three. I had already had issues with that, as I mentioned before.

For the moment, a “quick fix” is to manually set the initial stack size quite high. I think with this my current implementation works fine, but I hate such an ugly fix, which is too brittle anyway. I could choose std::list<>, so elements won’t be moved around in memory, but there might be another way.

That took far too long to diagnose…

One step forward, X steps backward.

Posted in LISP, programming with tags on August 18, 2008 by bbarrett

I’ve made some progress, but I think I’m after hitting a wall I didn’t anticipate. For your consideration, I will first post what I have working, then I’ll briefly discuss what isn’t and why I’m going in the wrong direction.
Continue reading


Posted in LISP, programming with tags on August 9, 2008 by bbarrett

Well, not really.

But I’ve come close:

(print (eval (readline)))

I’ve done a lot, although some of the big milestones that make a language useful aren’t finished.

Implemented to some degree:
* math functions
* list literals (I’ve fixed everything I could find with them)
* strings in quotes “”, which allow spaces and common escape characters
* multi line comments (again, lua style –[[ … ]])
* eval!

Eval is important, because using it I think I can “fake” control structures like if, while by using quoted arguments. I may even be able to implement defun. However, that would be a stop gap solution, one that I imagine would be very slow. Currently I am thinking of quoting the arguments to if and while, and just interpreting them on the fly.
Continue reading