[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[plt-scheme] Re: Ah. I understand.

On Sat, 8 Jun 2002, Robert Bruce Findler wrote:
> You got it!
> (Do you mind re-sending that message to the list? I've just moved our
> conversation back to the list with my last reply. I shouldn't have
> taken it off)

	With a bit of cleanup, my "Aha!" was why implementing my Scheme->Forth
compiler for the Mindstorm as a button as opposed to a language was a good

	I already have a subset of Scheme I'm working with; because the
compiler was developed outside of the greater DrScheme environment, my initial
reaction to drscheme:eval:expand-program was that I'd have to do more work to
get it down to the s-expression-based syntax of my compiler; a bit more
thought, and some experimentation made me realize a very cool side effect of
working with the primitive Scheme syntax.

	Any language implemented as a lang<%> is compiled down to the primitive
Scheme language described in the MzScheme manual.
	It's as simple as that.

	By working with this, I can compile (transform, whatever) primitive
Scheme into a syntax usable by my compiler--really, a straight-forward
transformation in this case. The benefits of this, though, are huge,
considering the applications I had in the back of my mind.

	First, I'd like to use this with students. I can easily extend Beginner
Scheme with primitives for the Mindstorm (a module that imports Beginning
Scheme, and exports all of Beginning Scheme with a few more primitives). This
leverages all the excelent error messages, etc., in Beginner Scheme--meaning I
don't have to recreate this effort for use with beginning students. Cool.

	It also means that I can save myself swapping firmware on the RCX.
For people who like NQC (Not Quite C---which requires but is limited by the
native firmware that ships with the LEGO), I can reimplement NQC as a new
language in DrScheme (just like Algol60), and my button to compile the
window to Forth will _still_ work, because the NQC-lang<%> will handle
compilation to primitive Scheme, and my code will step in to take that to

	Perhaps just as crazy, I can extend the Algol60 language to include
primitives for motor control, etc., and then you can program the LEGO Mindstorm
with Algol60. Granted, Algol60->Scheme->Forth is a long way around the block,
but processors are continuing to get faster every day... :)

	And if/when someone implements a LISP lang<%>, or Prolog, or Java, or
Haskell, or ... It wasn't until I was stumbling around trying to integrate this
into the environment that I realized how nice the abstraction layers were in
the language hierarchy.

	That's the expanded "Aha!" that Robby asked me to send to the list.


	PS - For those interested, I'm targeting Ralph Hempel's pbForth, an ANS
compliant Forth for the LEGO Mindstorm:


The compiler is written in collaboration with my colleague, Brooke Chenoweth.
After various things are cleaned up, some code belonging to others is properly
credited, it will hopefully move to Sourceforge in the Schematics project.

Targeting Forth is a stopgap until such time as I can implement a runtime for
the Mindstorm natively, and compile directly to the metal. The end goal is to
have a top-to-bottom environment where students can explore the design and
implementation of programming languages for small systems; that, at least, is
my current goal.