programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Snipped: reverse locals variables.

From: Charles Melice <mail_at_forthcad.com>
Date: Wed, 11 Oct 2000 12:28:44 +0200

A small definition to have local values in reversed order.

Is it to put in the tutorial ?

Have a good day,
Charles

\ -- cut code from next line --

OPTIONAL REVERSE-LOCALS.F

( LOCALS*| is like LOCALS|, but parameters are in reversed order. )

: reverse-params| ( -- )
    0 BEGIN >IN @ BL PARSE S" |" COMPARE WHILE SWAP 1+ REPEAT >R
    0 ?DO >IN ! BL PARSE PAD APPEND S" " PAD APPEND LOOP
    R> >IN ! BL PARSE PAD APPEND ;

: LOCALS*| ( -- )
    S" LOCALS| " PAD PLACE reverse-params|
    PAD COUNT EVALUATE ; IMMEDIATE

\ ---- Test ----

: a+b-c ( a b c -- res )
    LOCALS*| a b c |
    a b + c - ;

8 5 2 a+b-c . \ 11 = 8+5-2

\ eof
Received on Wed Oct 11 2000 - 03:35:50 PDT

This archive was generated by hypermail 2.2.0 : Thu Nov 20 2008 - 03:04:29 PST