Re: [stack] A question on joy syntax.

"Rahul" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
Taoufik Dachraoui <taoufik.dachraoui@...> wrote:

> in Joy:
> fact == [0 =] [pop 1] [dup 1 - fact *] ifte
 
> in v:
> [fact
>      [dup 0 =]
>          [pop 1]
>          [dup 1 - fact *]
>      ifte].
 
> In the second definition we explicitly manipulate the stack (dup) so  
> that the remaining code finds the stack in the expected state. In  
> this case dup is certainly faster than saving and restoring the  
---
> stack, but in other situations this may not be true.

  Would there be situations when this is less efficient?

  If we are modifying n members in the stack in the condition, then
  we may need to save only that n members rather than the entire
  stack. This we can do any way because the programmer is aware of
  the changes in stack. so that instead of above it might look like

  [dup_last_5
     do_stuff_on_these
     pop_these_out
  ] ... ifte

  But in case of ifte in joy, the interp has to reason about the 
  quotation and figure out the amount of stack effect, if it has
  to do the same. I am not sure if it is possible.
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.