Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #26764
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Forth200x enhanced locals implementation |
| Date | 2013-10-30 17:03 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2013Oct30.180302@mips.complang.tuwien.ac.at> (permalink) |
The proposal for the Forth200x enhanced locals proposal does not
contain a portable implementation, even though implementing the syntax
is possible portably (increasing the number of locals, also contained
in that proposal, requires carnal knowledge).
So I implemented the X:locals syntax portably, and you can find the
result in compat/xlocals.fs in
<http://www.complang.tuwien.ac.at/forth/compat.zip>.
There is an interesting insight in this implementation: I started out
with the <http://www.complang.tuwien.ac.at/forth/anslocal.fs> code
inspired by John Hayes' paper on implementing the { ... } syntax and
added the "|" option and some error checking.
The interesting change is that I switched from BL WORD COUNT to using
PARSE-NAME. This significantly simplified the implementation, as I
did not need to save and restore >IN, and reparse each local, but
could just keep the parsed string descriptors around.
The central words in the implementations are:
\ old \ new
: {helper ( -- final-offset ) : {helper ( f "name1"..."namen" -- )
>in @ parse-name1
bl word count 2dup s" |" compare 0= if
2dup s" --" compare 0= if 2drop drop true parse-name1 then
2drop [char] } parse 2drop true 2dup s" --" compare 0= if
else 2drop drop parse-rest exit then
s" }" compare 0= 2dup s" :}" compare 0= if
then 2drop drop exit then
if rot dup if \ we are in the | part
drop >in @ 0 postpone literal then
else recurse (local) ;
recurse
swap >in ! local
then ;
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2013: http://www.euroforth.org/ef13/
Back to comp.lang.forth | Previous | Next — Next in thread | Find similar | Unroll thread
Forth200x enhanced locals implementation anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-10-30 17:03 +0000
Re: Forth200x enhanced locals implementation "Alex McDonald" <blog@rivadpm.com> - 2013-10-30 22:23 +0000
Re: Forth200x enhanced locals implementation anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-10-31 12:06 +0000
Re: Forth200x enhanced locals implementation "Alex McDonald" <blog@rivadpm.com> - 2013-10-31 18:01 +0000
Re: Forth200x enhanced locals implementation anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-11-01 08:46 +0000
Re: Forth200x enhanced locals implementation "Alex McDonald" <blog@rivadpm.com> - 2013-11-01 10:36 +0000
Re: Forth200x enhanced locals implementation albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-10-31 14:21 +0000
Re: Forth200x enhanced locals implementation anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-11-03 14:22 +0000
csiph-web