Re: LAST definition

From: Mike Ghan <mikeghan_at_logix-controls.com>
Date: Fri, 13 Dec 2002 08:36:45 -0800

I'm not sure what you're after. Are you trying to trap errors at
compile time or run time? Maybe this is what you are looking for:

VARIABLE FAULT

: MY-WORD
    FAULT @
    IF [ LAST @ NAME> ] LITERAL >NAME COUNT TYPE
    ELSE ( CONTINUE AS NORMAL )
    THEN ;

or if used often:

VARIABLE FAULT

: ~MY-FAULT?~ ( xt -- flag )
    FAULT @ TUCK
    IF >NAME COUNT TYPE ." Faulted"
    ELSE DROP THEN ;

: MY-FAULT? ( -- )
    LAST @ NAME> POSTPONE LITERAL
    POSTPONE ~MY-FAULT?~
    POSTPONE ?EXIT ( or ABORT )
    ; IMMEDIATE

: MY-WORD ( -- )
   MY-FAULT? ( execution ends here if fault )
   ( Normal processing here )
   ." I didn't do it!" CR ;

----------------------------------------

Note that we saving the definition's xt as a literal and not it's name
field address. While not required for "normal" applications it is
required for a DLL.

Mike

-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
Behalf
Of Victor Kibby
Sent: Thursday, December 12, 2002 8:16 PM
To: sftalk_at_forth.com
Subject: [sftalk] LAST definition

I am after the definition of LAST or [LAST] & some advice I think
I wish to do somethin like the following
VARIABLE FAULT
: MY-WORD
    FAULT @
    IF ( use LAST or [LAST] here to print MY-WORD as being the last
defined word
)
    ELSE ( CONTINUE AS NORMAL )
    THEN ;
I would have many words like this
Thanks
Vic Kibby

--
Victor Kibby
----------------------------------------------------------------------
sftalk_at_forth.com      The SwiftForth programming discussion email list
To unsubscribe,  send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives!    Visit http://www.forth.com/search for details.
Received on Fri Dec 13 2002 - 08:36:01 PST

Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 09-Feb-2012. Archive updated nightly.