I’ve been recently hacking on fixing up the genius scoping rules. In particular, I solved a design issue by adding local variables. That is variables that are only visible in the current context. That way, functions passed as arguments need not see the internals the functions that call them. I was originally going to change the way lookup worked. I think the most natural rule would be to see variables that you could see when you were defined. So each function would save the context in which it was defined and then somehow “jump back to it” for the purposes of lookup. The problem is that I can’t figure out an efficient implementation of this idea. Especially with deep recursion this turns out to be deadly. So I implemented the local variables which are rather easy. That is if you have
function f(g,x) = (
function h(x) = x+a;
a = 2;
will return 12 and not 11. That is the function h will overlook the a and only see the a that was defined globally. An advantage of this approach is that it’s completely compatible. The only places where I’ve made incompatible changes were places where the current engine was buggy (for example it would keep substituting variables if a function was passed up again, though that is unlikely to happen much).
Also I have to rant about git. I tried reading up on it, since it seems that it is rather easy to screw things up with git. I consider myself not an extremely stupid person, but I still do not have a complete understanding of git. Mostly it seems like git does one million things that I will never ever use, nor would I ever dream of wanting to do, but it is very easy to do those things by mistake. It seems that what was previously simple (like merging changes) is now very complicated with lots of commands needing to be issued at the right order etc… Just the whole idea that there are now two types of commits (local and remote) seems absurdly idiotic to me. The fewer versions of the code there are the less chance for stupidities.
I said before git seemed like vcs masturbation. I have to revise this statement. Masturbation, while serving no purpose, is supposed to be fun. Using git instead of cvs or svn is not fun, it is painful (that could be fun for some people).
Maybe I’m just bitter today since I spent about half an hour trying to find a mistake caused by = instead of == in an if statement. Oh well, I think at least I’m pretty much done. The beast passes all current tests. It remains to document the new stuff and write more tests for the local stuff and then release. … Enough hacking … time to go do some math instead.