Well, for *zero* runtime overhead it's not possible without hacking
the compiler, but in less than 20 lines I think it's possible to make
a large-enough fixed-size stack with memory protection for overflow
which doesn't depend on dynamically scoped variable lookup. (Well,
what I'm thinking of wouldn't work well with continuations, but they
can be redefined.) However, this is not all that useful in general.
For one, if it's used for locals, then they're effectively dynamically
scoped, causing the funarg problem all over again. Additionally, if
they're going to have the same optimizations as >r and r>, then all
use of them must be balanced, so it would do nothing more than >r and
r> already do. In writing code in Factor, I've never encountered a
problem where >r and r> were too awkward to express what I wanted to
express, and I'm not sure what kinds of idioms would effectively take
advantage of this ability.

It's definitely an upside of locals that they have no runtime cost at
all, but the more important (and broader, easier) goal was that they
can be used with the optimizing compiler. Mutable locals do have a
runtime cost, though they can still be used with the optimizing
compiler.

Dan

On Mon, Apr 7, 2008 at 12:40 PM, Maxim Savtchenko <[EMAIL PROTECTED]> wrote:
> I thought, one of main ideas behind extra/locals is zero overhead in
>  run-time. Additional retain stacks in general form will be useful only
>  with optimizing compiler support. ">mystack" and "mystack>" should be
>  just as effective as ">r" and "r>". Is it possible with six lines of
>  code without special language features?

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to