![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

----- Original Message -----
From: "Mike Ghan" <mikeghan_at_logix-controls.com>
To: <sftalk_at_forth.com>
Sent: Tuesday, June 10, 2003 4:36 PM
Subject: [sftalk] Re: System to improve the LOCALS| legibility.
> A definite improvement. I would be inclined to change ":" to "=" or
> maybe ":=" to avoid confusion. There is a typo, the line
The modified version no more use "vocabulary".
I prefer =: because := is the Pascal assignement.
Thanks,
Charles
\ -----------------------------------------------
\ Other system to improve the LOCALS| legibility.
\ -----------------------------------------------
\ Usage example:
\
\ : Test ( D E -- )
\ [LOCALS \ Begins locals definition.
\ =: D \ : allocate+assign.
\ =: E
\ 1 =: A
\ 2 =: B
\ 3 =: C
\ LOCALS] \ Builds LOCALS|.
\ A B + C * D + E + . ;
\
\ -----------------------------------------------
256 constant (locals-pad-size)
(locals-pad-size) chars buffer: (locals-pad)
: [LOCALS ( -- )
s" |" (locals-pad) place ; immediate
: INSERT ( from nfrom to -- ) \ "insert-first" better ?
count locals| ntou tou nfrom from |
\ right shift destination string
tou
tou nfrom chars +
ntou chars
move
\ insert existing string
from tou nfrom chars move
\ update count char
ntou nfrom + tou 1 chars - c! ;
: LOCALS] ( -- )
s" locals|" (locals-pad) insert
\ cr (locals-pad) count type cr
(locals-pad) count evaluate ; immediate
: =: ( val "name" -- )
bl word count
\ check used size in local '(locals-pad)'
dup (locals-pad) c@ + 11 + (locals-pad-size) > abort" (locals-pad)
buffer full"
\ concat value name
(locals-pad) insert
s" " (locals-pad) insert ; immediate
\\ Test
: Test ( D E -- )
[locals
=: D
=: E
1 =: A
2 =: B
3 =: C
locals]
A B + C * D + E - . ;
10 20 Test \ -1 = (1+2)*3+10-20
\ -------- EOT -------
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Wed Jun 11 2003 - 01:36:55 PDT
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:32 PST