Next up, I'm going to start integrating Steve Wainstead's C++ patches into Stunt. This will give us better tools for abstracting away some of the complexity in the current codebase.

I haven't been doing anything with Waverous for months now and this is a shot in the arm. In part I took a deep dive into Minecraft and spent a lot of time on it -- a few hundred hours of playing time.

This is related peripherally to LambdaMOO development work in that some people still use MOOs to create and play games. The MOO I reside on does not do this, but one of the projects I want to pursue is use the package management system of Stunt to create some rooms and objects... I think prefabricated worlds (or even just portions of worlds) offer some good potential for wizards and world building. Imagine someone recreated the world of Harry Potter in a MOO: another person could contribute the Hogwarts Express, for example. The world builder might have two or three Hogwarts Express packages to choose from, offering different features. Todd's package management system will allow a level of sharing that was never possible before with LambdaMOO.

I haven't called AppleScript from Emacs in a while. Cooked up an Emacs command today to to make iTunes either play or pause, depending on its state. It's nothing fancy.
(defun sw-pp ()
"Make iTunes either pause or play"
(interactive)
(setq apscript "
tell application \"iTunes\"
if player state is paused then
play
else
pause
end if
end tell
"
)
(do-applescript apscript)
)

(An aside: I'm using the code HTML tag here to render the above code, which doesn't honor indentation. Using the pre tag double spaces the code, which strikes me as a bug).

Formally, I should use (let) instead of (setq) (which creates and sets a global variable) but I'm too lazy to work out the syntax. Writing Emacs Lisp is not yet second nature to me.

I was looking for a way to write to the *Messages* buffer only, and not to the "echo area" at the same time. The function message writes to both the "echo area" and the *Messages* buffer, which is too noisy for my little Emacs extension, desktop-auto-save.

This is for Exuberant Ctags, not the stock one that ships on some systems. If you run ctags --version and it doesn't tell you it's Exuberant Ctags you probably have a different version.

Cheetah is a templating system used in Python programming. I use it at work and yesterday I finally decided to do something about Cheetah template support in my TAGS file (I use Emacs; vim users will use a file called "tags").

Be sure to run ctags again to generate a new tags file; you may need to tweak the command line flags so ctags picks up your template files:

ctags -e -R --languages=-html,python

It's neat that this can be accomplished just through command line flags! I thought about writing an extension or a patch in C, but this small bit of work does pretty much all I need.

Trying 127.0.0.1...Connected to localhost.Escape character is '^]'.Welcome to Stunt! For information about Stunt, check out http://stunt.io/. To connect to the server, type "connect ".connect 14FC3656E763CB43C5E16F4CE9A9B77EE742629677A29048C44423C640A59442*** Connected ***

In truth, there's one more file that needs modification: exec.c, which uses goto as it was meant to be used but g++ doesn't like it. But that's a small obstacle to overcome.

By midnight last night I had the project successfully compiling, which was quite exciting. But the linking phase was failing; I found I was missing a handful of source files in Makefile.in, like json.[hc], collection.[hc] and a few others.

I think the Makefile.in is now up to date and I just have to update the files for File I/O to make g++ happy. After that, there's about 100-150 patches to look at but the vast majority of them are specific to my goals with Waverous, like including the LambdaMOO and JHCore databases, removing scripts used during porting, adding documentation, helper tools like Neil Fraser's Moo Database Browser, etc.

Today I wrapped up a bit of work needed in db_file.c where the TRY/EXCEPT/ENDTRY macros were replaced with their respective code. Somehow one block went missing during the patching process, and I compared files by eyeball between Stunt and Waverous to figure out where things went wrong.

I then applied a change from Stunt to Waverous, the first such change: Todd found the files ref_count.h and ref_count.c were never used since their innards were never seen by the compiler, being hidden by #IF 0 ... #ENDIF blocks.

I cleaned up Waverous's Makefile.in dependency list the usual hard way, which means getting the project to compile and running make depend. I have to revisit how this is done some day because there has to be a better way. Maybe this approach will work. (Edit: actually, with a little bit of thought it isn't necessary to get the project to compile... one just has to run the bison command plus a couple others to generate y.tab.h and parser.c, and then make depend will work fine).

I finally found what I was looking for in git: git-format-patch. Running this in the Waverous project for every commit from where I am now in the commit history to HEAD, I get 223 files. This sounds worse than it actually is:

Many of these are not germane to porting Stunt to C++. Some have funny names, and it's a lesson on why one should start every commit with what looks like a Subject: line, something I hadn't adopted while working in Subversion.

(This entry was written offline during a flight from Las Vegas to Milwaukee today, June 21st 2012. I'm continuing the task of merging Waverous into Stunt, or put another way, getting Stunt to be C++ compliant).

I never caught this when I ported Waverous to C++ because I never defined BYTECODE_REDUCE_REF. This suggests to me a way of testing the server by compiling it with every possible combination of flags... this would be one hell of a build-and-smoke test. For every combination of compile-time options: compile the server, start it up, log in and do some basic tasks, shut down. I would have caught this long ago if I'd thought of writing such a test.

After some dedicated surfing via my phone at Milwaukee's airport, which does not have free wi-fi (pththth) I found the solution on www.cplusplus.com:

It's curious and non-obvious to me that the args within the function are cast and that this satisfies the compiler. On a side note I think being able to google our compiler errors and find solutions is an exception to Fred Brooks's "No Silver Bullet" argument. It feels like an order of magnitude increase in productivity to get help so easily.

I'm now past one of the stickier parts of porting: past the TRY/EXECEPT/ENDTRY preprocessor macros in code_gen.c. I had to edit the file by hand and incorporate the needed expansion of the macros because the block of code in question had added blank lines spacing out the code. I would think patch would have a command line flag to account for this situation, but patch can only handle changes in leading and trailing whitespace.

I'm making progress patching my fork of Stunt LambdaMOO by generating patches from the git log of Waverous LambdaMOO. There have been the occasional rejections by patch that have puzzled me a bit; I wonder if it's a white space problem? I doubt it. I didn't look terribly close because doing the edits by hand only took a minute. I'm now up against the dreaded TRY/EXCEPT/ENDTRY set of C preprocessor macros. By my commit log in Waverous:

Geez, that was three years ago? I was hacking away in my little second-bedroom-turned-office in Jackson Heights, Queens; and these days I'm in a high rise in downtown Las Vegas.

Anyway this patch was completely rejected. It's late and my brain is too short on glucose to get the job done. Time to push to master and try to catch up on MOO-talk again. I can't keep up with it lately!

I didn't have oodles of time so I let it slide for a few weeks... my time was being taken up by a Udacity course, running LVDev, campaigning for a political candidate, working on a GreenerBlocks.org project and more! But the itch is there and wants scratching. Tonight I packed my laptop and went over to the Vegas Jelly in /usr/lib above The Beat Coffeehouse. It meets every Thursday night. The Linux, Bitcoin and All Things Open Source group was meeting in the conference room (Hi, Julian!) and I took a seat in the back of the room. I worked while a debate raged about the prospects of Bitcoin but I barely took notice. What I first found was gcc, make and friends were not present on my system anymore. I upgraded my laptop to OS X Lion recently when I participated in an iOS Boot Camp. But I installed XCode; wtf? Googling told me I needed to install the command line tools via Preferences -> Downloads. Completely obvious in retrospect, heh. I renamed configure.in to configure.ac, copied my Waverous version of the file over it and ran autoconf. All good. I ran ./configure:

Another wtf moment. I googled around but didn't really find anything specific enough for my situation; maybe upgrading the autotools? I did port update on autoconf and automake; but still the same error. Finally I just copied install-sh from the automake directory; this is scratch hacking after all, and with version control you never have to say you're sorry. (EDIT: Duh, I forgot to run automake --install-missing, was all).

OK, more wtf material... I called it an evening, had a nice discussion with a couple of the Linux guys about LambdaMOO and the problems of getting the masses to use new software, and headed home.

Back in my home office I googled the error a bit, editing out the particulars of the error message to make the search query more generic; somewhere I found one forum post where the reply was "Your aclocal got borked." Ah! Did I not move some of the MOO m4 macros to another file to reduce the size/complexity of configure.ac?

So I copied acinclude.m4 over from the Waverous project, ran aclocal, ran autoconf and finally ./configure and everything went well. I now have a Makefile that will correctly call g++ for the project. Time to commit my work, push it to github and sleep on it a bit.

What comes next, should I undertake it, is a lot of bare knuckle hacking to resolve conflicts between Waverous's code base and Stunt's. Todd has made a lot of edits to the C sources, I'm sure, and I started from the most recent version of LambdaMOO on Sourceforge. It means I'll have to come to understand a lot of the changes Todd made, and that will be challenging.