[Fwd: [stack] Digest Number 26]
Massimo Dentico
m.dentico@teseo.it
Fri, 02 Jun 2000 19:33:33 +0200
on concatenative@egroups.com "Dr. Stephan Becher" wrote:
> > Massimo Dentico <m.dentico@teseo.it> wrote:
> >
> > wtanksley@bigfoot.com wrote:
> > > [...]
> > > BTW, I've been talking with the guy who implemented the strong typesystem
> > > for Forth, and it turns out that the language IS the typesystem for him. He
> > > is using the Forth way of doing things after all. You can include any Forth
> > > code in the type declarations.
> > > [...]
> >
> > It's interesting. I have missed various messages on comp.lang.forth
> > because of my move to another city. Is he Stephan Becher? Is he
> > publishing his work on the net?
> >
> > Thanks.
>
> Yes, that's me. :-)
>
> I already promised to supply the Forth community with an
> as-far-as-possible ANS compatible version of my strongly typed
> Forth, including documentation, by the end of July. An older
> version that produces optimized native code, is already
> finished, but it is non-standard and would require a lot of
> documentation, which only partly exists (in german, not in
> english). Therefore I do not intend to publish this.
>
> Following are some details on the type mechanism in advance.
>
> There exists a hierarchical type structure with two types,
> SINGLE and DOUBLE at the top level. The second level inludes
> types like INTEGER, ADDRESS and LOGICAL as subtypes of SINGLE,
> and for example INTEGER-DOUBLE and TOKEN as subtypes of DOUBLE.
> Most second-level types have further subtypes. The type
> hierarchy can certainly be extended by user-defined types
> without any limits.
>
> Each Forth word has a stack diagram assigned to it, which is
> stored as part of the dictionary. When defining a new word, one
> has to specify the stack diagram in the usual Forth style, for
> example:
>
> : SPACES ( UNSIGNED -- ) ... ;
>
> If the stack diagram is left out, as in
>
> : ." ... ;
>
> the word is assumed to have neither input nor output
> parameters.
>
> ( is an immediate word, which puts a status code of data type
> STACK-DIAGRAM onto the stack and enteres interpreter mode.
> Thus, the following words up to ) are normal interpreted Forth
> words. UNSIGNED adds an input parameter of type UNSIGNED to the
> definition of SPACES into the dictionary and modifies the
> status code. Further input parameters can follow. -- does some
> checks on the status code and modifies it in a way so that from
> now on output parameters are generated. Finally, ) does
> additional consistency checks, initializes the data type stack
> with the just defined inpur parameters and re-enters compiler
> mode. Since the whole stack diagram is just interpreted Forth
> code, words like
>
> : 2*INTEGER ( STACK-DIAGRAM -- STACK-DIAGRAM ) INTEGER INTEGER
> ;
>
> or even
>
> : N*INTEGER ( STACK-DIAGRAM UNSIGNED -- STACK-DIAGRAM ) 0 DO
> INTEGER LOOP ;
>
> can be defined. Also very interesting is
>
> : STRING ( STACK-DIAGRAM -- STACK-DIAGRAM ) CDATA -> CHARACTER
> UNSIGNED ;
>
> The latter example requires some explanation. Since pointers
> are strongly typed, it has to be specified where they point to.
> CDATA is a subtype of DATA, which is itself a subtype of
> ADDRESS. To be able to use more than 64k of memory, I have
> divided the address space, thus DATA is an address in the RAM
> part of the data space. CDATA is the address of an object of
> character size, while DATA usually addresses cell sized objects
> (16 bit on a 16-bit machine). -> is a Forth word that connects
> CDATA and CHARACTER, meaning that this is only one parameter,
> namely a data space address of a character.
>
> There are certainly much more details to this concept. I've
> tried to keep everything as simple as possible and as
> Forth-like as possible. Please accept that I can't provide too
> many details right now, because I would rather keep my promise
> and have a real version finished by the end of July.
>
> Stephan
>
--
Massimo Dentico