[<<][staapl][>>][..]
Sun Mar 22 21:51:26 CET 2009

Forth and data structures

There is a clear link between lazy function application and data
structure pattern matching in a functional programming language.  The
body of a pattern matching clause behaves as the body of a function:
the data structure "transports" the parameters of datastructure
construction to the datastructure deconstruction binding environment,
much like the invokation of a function does.

In Forth this isn't so clear because there are no lexical binding
forms.  To get a similar behaviour, a data structure should be
"executable" and load a number of values on the parameter stack,
however, this is impractical.

I have the impression that Forth is better at "process" oriented
programming instead of data structure manipulation: data structures
are about postponing interpretation, while embedded processing is
mostly about immediate action/reaction: there is more code than data.

This is exactly the reason why I moved to Scheme to implement the
compiler (compile time data structure interpretation).

Can this be made into some kind of mantra?

       process           <->         structure
       RUN                           COMPILE

Or put differently: When writing highly specialized lowlevel code, try
to avoid datastructures, or only use the datastructures at compile
time.  Think of that which would be the result of deforestation in a
FP language, and write it directly, or pass the datastructures between
macros.  Deforestation is essentially jit-compilation: eliminate
intermediate (code) representation.



[Reply][About]
[<<][staapl][>>][..]