GIGO: words unreadable aloud
Mishrogo Weedapeval
 

 

  Tuesday 10 July 2007
Stalled SECD Work

Being the ongoing but abridged saga of a translation of a deconstructed abstract machine (interpreter) for a fairly basic lambda calculus, due to Peter Landin (the original 1964 SECD machine) and Olivier Danvy (the 2003 deconstruction), said translation starting with SML, detouring through Ruby, and stalling out for no intrinsic reason with a partially working OCaml version.

In our last episode (May 2007) I wrote: "The machine part compiles; maybe I'll be able to get the test app running later this week."

It being July now, that'd have to be a heck of a week. Fact is, I've been finding precious little time to work on it, with some major deadlines at work and other personal issues intruding.

But I do recall that I never put the OCaml version up anywhere, and since I haven't even touched it in over three weeks, I figured it must be time to put it up here so I can find it later.

Caveats: I've only compiled it on my old Mac at home, with Ocaml version 3.06. And it's not fully debugged yet, either. But it does say helpful stuff like this:

Evaluate 0 ... 
Evaluating     <LIT 7>
      result   7
Evaluating     <LIT 3>
      result   3
Evaluating     (\x -> [succ _ x])
      result   (E:<[ succ =succ
        ]>, V:x, T:[succ _ x]:)
Evaluating     [(\x -> [succ _ x]) _ <LIT 8>]
      result   9
Evaluating     (\x -> (\y -> [succ _ x]))
      result   (E:<[ succ =succ
        ]>, V:x, T:(\y -> [succ _ x]):)
Evaluating     [(\x -> [succ _ x]) _ <LIT 7>]
      result   8
Evaluate 3 ... Evaluating     <LIT 7>
      result   7
Evaluating     <LIT 3>
      result   3
Evaluating     (\x -> [succ _ x])
      result   (E:<[ succ =succ
        ]>, V:x, T:[succ _ x]:)
Evaluating     [(\x -> [succ _ x]) _ <LIT 8>]
      result   9
Evaluating     (x -> (y -> [succ _ x]))
      result   (E:<[ succ =succ
        ]>, V:x, T:(y -> [succ _ x]):)
Evaluating     [(\x -> [succ _ x]) _ <LIT 7>]
      result   8

At any rate, there are just two source files, so I didn't put together a Makefile or anything. They're here:

http://got.net/~landauer/cs/ohdr.ml
http://got.net/~landauer/cs/Danvy_SEC_M.ml

Though the current result is of somewhat questionable utility, I found it to be worth my time, since I did learn:

  • more OCaml;
  • how much FP-style pattern matching helps code conciseness; and
  • how much extra but necessary infrastructure stuff can be glossed over (i.e., omitted) in a technical paper like Danvy's.

11:55:33 PM   comment/     


Click here to visit the Radio UserLand website. Click to see the XML version of this web page. © Copyright 2007 Doug Landauer .
Last update: 07/8/17; 23:53:36 .
Click here to send an email to the editor of this weblog.

July 2007
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Jun   Aug

Previous/Next