Re: 5(?) concatenative L's

Slava Pestov — 2004-08-14 06:08:43

Manfred,

I think it would be nice if each section of the comparison could assume
basic concepts from the prevoius. Then, ideas could be introduced in
this order;

- Intro -- basic concatenative model
- Your Joy guide, I guess this would mention higher order combinators
such as ifte and linrec
- John's Forth guide -- presumably this would mention forth's chained
execution (parsing words & running words).

I'd like the Factor section to have two parts on what makes Factor
differ from the other languages, namespaces and continuations.

I'll ask Chris Double to write a section on continuations, since he
seems to understand them best :-)

Here is a skeleton draft of a description of basic features and
namespaces; feel free to comment:

----

Factor code is composed of nested quotations, which themselves are lists
of words and literals such as strings and numbers. Dynamic typing and
automatic storage management is provided.

A simple expression evaluating to a complex number:

5 3 dup * - sqrt .
===> #{ 0 2 }

Evaluation follows a strict order and side effects are allowed. In
addition to Joy-style functional lists, Factor supports mutable vectors.
From vectors, hash tables and stacks may be constructed.

Factor implements the notion of "variables" and "scope" by maintaing a
global "name stack" consisting of hashtables with string keys. The word
"get" searches the name stack from the top down for a value with a named
key, while the word "set" changes the value in the hashtable at the top
of the name stack:

5 "x" set
"x" get .
==> 5

A combinator is provided for executing a quotation while pushing and
popping a hashtable on the name stack:

<namespace> [ 5 "x" set ] bind

Slava