Newsgroups: | comp.compilers |
From: | ridoux@irisa.fr (Olivier Ridoux) |
Organization: | IRISA, Rennes (Fr) |
Date: | Tue, 4 Aug 1992 10:55:15 GMT |
Keywords: | C, prolog |
References: | 92-07-095 |
>[one can write more-or-less continuation passing C code with this loop:]
> while (TRUE) { cont = (*cont)(); }
Everybody knows about this technique. We are actually using in Prolog.
We are calling the above loop the "motor". But to split a program in as
many C functions as there are storable control points is not reallistic.
E.g. in Prolog, it is fair to map every predicate onto a C function, but
to go further is a non-sense as far as efficiency is concerned. One wants
to be able to goto from a clause to another one inside a predicate, yet
one also want to store and read a clause label for handling bactracking.
Furthermore, some useful improvements come easily if C functions
correspond to a high-level semantical unit. E.g. in Prolog, (I suppose
something similar can be done for a functional language) left-recursive
clauses need not return to the motor, they merely have to loop.
Left-recursion translates to iteration.
Splitting into too small bits also hinders any chance for locality.
Olivier Ridoux
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.