Technics to improve (?) the sources readability.

From: Charles Melice <mail_at_forthcad.com>
Date: Wed, 4 Dec 2002 13:12:15 +0100

I'm searching for technics to improve the sources
readability.

Is there some other system to propose ?

Charles

\ ----------------------------------------------------
\ Prefix operator { } to improve source readability.
\ ... but break the comment {, replaced with {*
\ ----------------------------------------------------

REQUIRES STACKS

16 STACK (post-stack)

: (later) ( -- )
    (post-stack) TOP (post-stack) POP
    state @ If compile, Else execute Then ; immediate

: {* postpone { ; \ save it

: { ( "name" -- )
    ' (post-stack) PUSH
    ['] (later) (post-stack) PUSH ; immediate

: } ( -- )
    (post-stack) TOP (post-stack) POP execute ; immediate

\\ {* program text samples (cannot interpret) *}

* without {}

    : OnInitDlg ( -- )
        HWND 99 GetDlgItem >R
        R@ FCV_SET_PROJECTION 0 MSG>VIEW drop
        R@ FCV_ADD_OBJECT CreateCube MSG>VIEW drop
        R@ FCV_SET_RENDMODE 2 MSG>VIEW drop
        R@ FCV_VIEW_KEY 0 MSG>VIEW drop
        R> drop ;

* without {}, improved presentation

    : OnInitDlg ( -- )
        HWND 99 GetDlgItem >R
        R@ FCV_SET_PROJECTION 0 MSG>VIEW drop
        R@ FCV_ADD_OBJECT CreateCube MSG>VIEW drop
        R@ FCV_SET_RENDER_MODE 2 MSG>VIEW drop
        R@ FCV_VIEW_KEY 0 MSG>VIEW drop
        R> drop ;

* with {}

    : OnInitDlg ( -- )
        { GetDlgItem HWND 99 } >R
        { MSG>VIEW R@ FCV_SET_PROJECTION 0 } drop
        { MSG>VIEW R@ FCV_ADD_OBJECT CreateCube } drop
        { MSG>VIEW R@ FCV_SET_RENDER_MODE 2 } drop
        { MSG>VIEW R@ FCV_VIEW_KEY 0 } drop
        R> drop ;

    : CB-GetSelText ( id buf -- flag )
        dup off
        over { SENDMSG ( id) CB_GETCURSEL 0 0 }
        dup 0< IF 3drop FALSE EXIT THEN
>r >r { SENDMSG ( id) CB_GETLBTEXT r> r> swap } -1 > ;

----------------------------------------------------------------------
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 Wed Dec 04 2002 - 04:09:37 PST


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

This archive was generated 02-Sep-2010. Archive updated nightly.