Inlining in Joy

John Cowan — 2001-04-27 20:24:20

(Manfred, you and I seem to be talking to ourselves, but what
the hell...)

Joy lends itself to extremely easy inlining: when defining a
word, you can simply replace any user-defined word in the body
with *its* body, recursively, but watching for references to
words already being inlined (so that you do not get into an
infinite expansion). The implementation should be extremely
easy.

However, I can think of at least three policies for deciding
whether to inline or not:

1) Mark inlineable words (e.g. by starting the definition
with INLINE instead of DEFINE/LIBRA). Any word so marked
is always inlined when it is used in a definition, subject
to the caveat above.

2) Have a global mode: when on, we do inlining on every
definition; when off, we don't inline during definition.
(Once a definition is inlined, it stays inlined regardless
of the mode.)

3) Just inline everything.

In any case we also need a small dependency tracker so that
we can decide what definitions get broken when a definition
that they inline gets changed.

Any thoughts, anyone? Do Forth compilers inline? What
about dependency tracking?

--
There is / one art || John Cowan <jcowan@...>
no more / no less || http://www.reutershealth.com
to do / all things || http://www.ccil.org/~cowan
with art- / lessness \\ -- Piet Hein

Mark van Gulik — 2001-05-05 23:55:21

If you do choose to use "(" and ")" for grouping disjuncts, I suggest that
fail be the special case "()". Think of it as zero disjuncts, and hence
impossible to satisfy.

-Mark

Manfred von Thun — 2001-05-08 01:56:58

On Sat, 5 May 2001, Mark van Gulik wrote:

> If you do choose to use "(" and ")" for grouping disjuncts, I suggest that
> fail be the special case "()". Think of it as zero disjuncts, and hence
> impossible to satisfy.
Nice idea -- at least if disjunction is the only other binary
operator apart from (the implicit) concatenation (operator).
Otherwise there is bound to be trouble. Also, the use of
parentheses to override precedences is the only use (apart
from the four others in, say Pascal, and the Lisp/Scheme use)
where (..) is entirely equivalent to ((..)) .
- Manfred