I think that a function like bind could be more intersting. Something like:
1 2 3 4 [ a b c d ] [ a b + c d + + ] bind
The function will automatically create local variables (local only on the
second seq) using the values from the stack.
And in a more advanced version it can be used to create functions with
parameters:
:bind sum-of-4-numbers ( a b c d -- x ) a b + c d + + ;
On Mon, Apr 7, 2008 at 10:23 AM, janko metelko <[EMAIL PROTECTED]> wrote:
> I was proposing this on irc too... multiple retain stacks that you can
> create and name on your own. And then also important is that stacks would
> have not just push, pop functionality but also peek (so that value stays on
> stack)
>
> but I don't like your syntax that much, why would you have to define them
> and use some structure (block) where there I don't see the need for it.
>
> >people (could silently create and PUSH on them if they aren't yet
> created, or a special syntax could be made for this to be)
>
> people> (POP)
>
> people|> or people (or something else for PEEK)
>
> best regards,
> janko
>
>
> On Sun, Apr 6, 2008 at 11:41 PM, Maxim Savtchenko <[EMAIL PROTECTED]>
> wrote:
>
> > I have mixed feelings about extra/locals library. It is good to have
> > local named storage, but current design of extra/locals looks very
> > "lispish" (FP-style immutable variables). I think, there is a way to
> > make it closer to Factor stack-shuffling paradigm. So I have a
> > suggestion. What if we can use not local variables, but local
> > additional retain stacks, just like ">r" and "r>"? Let me show you
> > this concept on example from recent Slava's blog-post:
> >
> > :: julian-day-number>date ( n -- year month day )
> > #! Inverse of julian-day-number
> > [let* | a [ n 32044 + ]
> > b [ 4 a * 3 + 146097 /i ]
> > c [ a 146097 b * 4 /i - ]
> > d [ 4 c * 3 + 1461 /i ]
> > e [ c 1461 d * 4 /i - ]
> > m [ 5 e * 2 + 153 /i ] |
> > 100 b * d + 4800 -
> > m 10 /i + m 3 +
> > 12 m 10 /i * -
> > e 153 m * 2 + 5 /i - 1+
> > ] ;
> >
> > This is how it looks with lisp-style locals. And here is my suggestion:
> >
> > : julian-day-number>date ( n -- year month day )
> > #! Inverse of julian-day-number
> > [rest n a b c d e f | >n
> > n 32044 + >a
> > 4 a * 3 + 146097 /i >b
> > a 146097 b * 4 /i - >c
> > 4 c * 3 + 1461 /i >d
> > c 1461 d * 4 /i - >e
> > 5 e * 2 + 153 /i >m
> > 100 b * d + 4800 -
> > m 10 /i + m 3 +
> > 12 m 10 /i * -
> > e 153 m * 2 + 5 /i - 1+
> > ] ;
> >
> > "[rest" - is fo REtain STacks. It creates additional local stacks with
> > accessors to them. Each stack ("x" for example) have three accessors.
> > Traditional ">x" and "x>" with semantics of ">r" and "r>". And
> > abbreviation "x" with semantics of "x> dup >x". At the end of "[rest
> > ... ]" block remaining values on additional stacks are simply
> > dismissed. Looks good for me.
> >
> > This raises major question. Is it possible to compile efficient code
> > with more than one retain stack?
> >
> > Maxim Savchenko.
> >
> >
> > -------------------------------------------------------------------------
> > 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
> >
>
>
> -------------------------------------------------------------------------
> 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
>
>
--
float e,a,b,c,d;int i;main(){for(b=0;b<4;b
+=.091){for(a=0;a<4;a+=.051){c=0;d=0;for(i
=99;--i&&c*c+d*d<4;)e=c*c-d*d+a-2,d=2*c*d+
b-2,c=e;putchar(". ยท*%#"[i&5]);}puts("");}}
-------------------------------------------------------------------------
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