Gerry Jackson wrote:
> : \s source-id file-size throw ( -- ud )
> source-id reposition-file throw ( -- )
> ;
>
> However the Forth 200X committee decided that was not a valid thing to
> do and banned it in the Forth 2012 document.
It's not something you can rely on.
> But IIRC it used to work in GForth and perhaps still does.
My point of view is that a quality implementation should honor this,
following the principle of least surprise. If you want to optimize, e.g.
slurp in the entire file (or bigger chunks of it) and then present it line
by line to the interpreter, you can as well implement FILE-POSITION and
REPOSITION-FILE in a way which works on buffers. After all, we do use C's
io buffers in Gforth, which work like that.
You should add a POSTPONE \ to make sure that the rest of the \S line is
also commented out.
BTW: no need to implement it, Gforth already has \\\ which has the same
effect. It's implemented portably, i.e. it first does the REPOSITION-FILE
thing, and then a REFILL loop, and finally the POSTPONE \.
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
http://bernd-paysan.de/