Prism Metaprogramming Tool released

James Little
Sat, 23 Oct 1999 21:39:41 -700

> >>>>> "Jim" == Jim Little <> writes:

>   Jim> Prism development will proceed in four phases: * The "assembly
>   Jim> language" phase.  * The "modern language" phase.  * The
>   Jim> "domain-specific language" phase.  * The "TUNES" phase.
> Is it real necessary to have these 4 phases ? Why should we define
> integer arithmetics before object orientation ?

Hmm, good question.  The short answer is that new Prism languages are written with existing Prism languages.  It's easier to start by creating small building blocks, then using those to create larger structures.

>   Jim> Here's the detailed plan for the first phase and the beginning
>   Jim> of the second: * Create a parser for integers * Create programs
>   Jim> to do integer arithmetic 
> To be honest, integer arithmetic is alsmost the first thing I've done
> with OIL :-). But I didn't have to create a parser. I'll probably do
> one in the future, but it is not required.

Integer arithmetic is the first thing we'll do with Prism, too.  :)  Once we have integer arithmetic, we can write meaningful program.  Our first meaningful program will be an assembler metaprogram for the Prism virtual machine.  To create the assembler, we need the ability to parse integers.

(Right now, there's an assembler, but it's written in Perl.  We need to bootstrap Prism by porting the assembler to the Prism Control metamodel.  Prism Control is the Prism VM's "machine code".)

> To avoid the parser, I just
> defined two functions bin2int and int2bin, to convert from list of `0'
> and `1' to integers, and vice-versa. Therefore, the user can type :
>         add [bin2int (1 1)] [bin2int (1 0 1)]
>         => 10094
>         bin2int 10094
>         => 10096 = (1 0 0 0)
> (Yes I kow, the syntax is very unsual). 

It would be possible to do something similar in Prism -- you could specify the integer models directly -- but that gets pretty tedious after a while.  :)

Prism integers, by the way, look like this:

_List {           # The integer '-7'
   _Bit {BAR}
   _List {
      _Bit {FOO}
      _Bit {FOO}
      _Bit {FOO}

(The language -- Prism/Atom -- isn't very compact, but that's intentional.  Prism's very nature means that this language will be abstracted from most people's view.)

> So we can do an addition without having to parse integers. 

Definitely true.  I didn't mean to imply that we had to write the integer parser before we could implement integer arithmetic.  Rather, both are necessary before we can create the Prism/Control assembler.

By the way, where can I learn more about OIL?