So I thought I'd write a quick little language implementation in
OCaml, since (a) OCaml is sort of optimized for writing languages and
(b) I wanted to learn OCaml, including ocamllex and ocamlyacc.

(b) is a big reason for doing things the way you did, but I thought I'd point out that, as with LISP or FORTH or dc(1), in APL lexing and parsing are nearly trivial* -- possibly due to deliberate design decision, possibly to due to the nature of machines (and lack of language theory!) at the time. It might be interesting to see what changes were made to apl when it went from being a human-centered didactic notation to a machine-implementated executable one.

-Dave

:: :: ::

* subscripting may have been an exception, hence its absence in J?

For instance, if one carries the environment in machine state,

  x*x:a+b

can be scanned a character at a time and directly translated to {load b; add a; store x; mul x}, while more modern equivalents,

  x*x where x=a+b
  let x=a+b in x*x

involve some minor parsing first.

Reply via email to