Re: [stack] Constant folding algorithm

"William Tanksley, Jr" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
Daniel Ehrenberg <[email protected]> wrote:
> Right now, I'm working on a module called inverse for Factor. The
> basic goal is to provide an inverse (or, technically, a section) of a
> quotation, for a generalized form of pattern matching. I've noticed

Wow, that's impressive.

> that this can work both more efficiently and more generally if I first
> perform constant folding on the quotation, for example transforming [
> 1 2 + * ] into [ 3 * ], which can more easily be inverted. Right now,

That makes sense. A friend of mine has an algorithm for Forth which
seems to catch a lot of opportunities for optimization (including
stack manipulation and constant folding); I'll see if I can convince
him to either write it up or join this list. In essence, he uses a
stack at compile time to track the type and knownness of values
encountered and/or produced. It's linear time, so it's not hard to
understand.

> looks like one area where it's a little easier to manipulate an
> applicative programming language than a concatenative one, though I'm

Heh. I doubt it.

> Daniel Ehrenberg

-Wm
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.