Big Messy Update, Volume I
Time for a break
A quarter goes by very quickly here. I learned about American Sign Language, computing theory (languages, automata, Turing machines, and complexity theory), artificial intelligence, and programming language theory (PLT).
I designed and implemented some small programming languages, using the Scheme programming language and tools provided by Friedman, Wand, and Haynes. PLT was a really cool course, covering in great depth how basic concepts of programming languages — scope, recursion, types, type checking, etc. — are implemented. Below are a few examples of the last language I designed for this course. Along with sample code, I had to design the grammar and lexical specifications and implement the entire interpreter (sans type checking).
Recursive factorial
-
! if statement is one statement so it doesn’t -
! need surrounding braces. -
var factorial2 { -
factorial2 = proc (n) -
var x; -
if greater?(n, 0) then -
var subfac; { -
subfac = (factorial2 : [n - 1]); -
x = [x * subfac]; -
print n; } -
else -
x = 1 ! note no need for semicolon -
endif -
returns: x -
; -
print (factorial2 : 5); -
}
5 4 3 2 1 120
More interesting code
-
! simulating the greater-than predicate -
var gt0, x { -
! returns zero if non-positive. returns positive number otherwise. -
! the $ character is the sign operator -
gt0 = proc(x) -
var abs; abs = proc(n) returns: [n * $n]; -
returns: [x + (abs: x)]; -
x = 5; -
if (gt0 : x) then -
print 1 -
else -
print -1 -
endif; -
}
1
Interesting features of this language: algebraic expressions are enclosed in [square brackets]. This came about as a way to work with the LL(1) parser generator, but it winds up giving my language a unique personality. Procedure declarations are expressions, as inspired by Scheme. Procedure calls appear between parentheses, with the procedure expression separated from parameters by a colon. Because of the way procedures are required to have exactly one exit (return) point, some interesting syntax is possible (as with the gt0 predicate above). Overall, it’s an untyped, highly block-structured langauge, with first-class procedures and recursion.
And…
I worked with another student on another project having a long title for AI class. This one is titled Wireless Sensor Nodes as Intelligent Agents: Using Expert Systems with Directed Diffusion. I found no way to avoid the dreaded two-colon-separated-clauses title.
Current projects
During Thanksgiving break, I’m doing freelance web development (ColdFusion) work, implmementing genetic algorithms for fun, working on WebAppAdmin, and beginning design on a Civilization-style game. A couple of future posts may appear about these topics.
Camino
This is a little belated, but: Camino 1.0 beta 1 is available for public consumption! I immediately installed and it has been rock-solid, with absolutely no problems. Great job and thanks to all of the Camino developers. I would like to join that group some day, after getting some experience with Cocoa.