In article <
[email protected]>,
Anton Ertl <
[email protected]> wrote:
dxf <[email protected]> writes:
If I use locals I'm more likely to
use the ANS notation. I notice Forth Inc does too - perhaps why they were so >>adverse to conceding to { } .
The reason why Forth, Inc. argued against { } is that they support an >existing code base that uses { } for comments; they use { } comments >extensively in SwiftForth, and their customers use it, too. They
voted for {: :}, so they obviously don't have a problem with the
ordering of locals in {: :} (which is the same as for { }).
Not knowing Swiftforth I have introduced { } for anonymous code snippets
for ciforth. These anonymous snippets work the same in interpret and compile mode,
{ DROP } EXECUTE
: xxx { DROP } EXECUTE ;
They must look familiar to those who use "normal" languages ;-) .
(swiftforth has a point too, { } is used for comment in Pascal.)
The dispatch table for equality in my lisp (version based on Mark Probst)
looks like:
"
\ For respective: nil pair number builtin symbol special compound
0
{ = lisp-flag }
{ = lisp-flag }
{ number-num swap number-num = lisp-flag }
{ = lisp-flag }
{ >R symbol-name R> symbol-name $= lisp-flag }
{ = lisp-flag }
{ = lisp-flag }
(create-table) TO eq?-dispatch
"
Now introduce :NONAME and be surprised how clunky this becomes.
The implementation didn't cost me an arm and a leg:
"
' TASK @ CONSTANT DOCOL
\ Denotation for lambda, ends with `}
: { 'SKIP , (FORWARD HERE DOCOL , HERE CELL+ ,
STATE @ 1 STATE ! ; IMMEDIATE
: } '(;) , STATE ! >R FORWARD) R> POSTPONE LITERAL
; IMMEDIATE
"
Considering the elementary character of this, it is written out
for speed.
If you have available the 4 brackets of the apocalypse it is
more straightforward:
: { (( (s ({) ; IMMEDIATE
: } >R (}) s) )) R> 'LITERAL EXECUTE ; IMMEDIATE
[ LITERAL is the only state smart word in ciforth.
In interpret mode it does nothing.
In compile mode it compiles a literal. ]
As a reminder the 4 brackets:
\ Compact version of :NONAME .. ; not linked in.
({) .. (})
\ Nest dictionary space.
(( .. ))
\ (s s) save and restore STATE.
(s .. s)
\ Nest definitions (not used in the above)
([) .. (])
In a complex Forth these words may be difficult to implement.
- anton
Groetjes Albert
--
Temu exploits Christians: (Disclaimer, only 10 apostles)
Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
And Gifts For Friends Family And Colleagues.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)