Sujet : Re: Parsing timestamps?
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forthDate : 24. Jun 2025, 17:37:05
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2025Jun24.183705@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5 6 7 8 9
User-Agent : xrn 10.11
minforth@gmx.net (minforth) writes:
On Mon, 23 Jun 2025 5:18:34 +0000, Anton Ertl wrote:
>
minforth@gmx.net (minforth) writes:
So, I made me a small extension to the locals word set. Using your
example SPIN (abc — cba), I can define it as follows:
: SPIN { a b c == c b a } ; \ no need for additional code before ;
>
What is the advantage of using this extension over the Forth-2012:
>
: spin {: a b c :} c b a ;
>
?
>
Obviously, there is no advantage for such small definitions.
>
For me, the small syntax extension is a convenience when working
with longer definitions. A bit contrived (:= synonym for TO):
>
: SOME-APP { a f: b c | temp == n: flag z: freq }
\ inputs: integer a, floats b c
\ uninitialized: float temp
\ outputs: integer flag, complex freq
<: FUNC < ... calc function ... > ;>
\ emulated embedded function using { | xt: func }
< ... calc something ... > := temp
< ... calc other things ... > := freq / basic formula
< ... calc other things ... > := flag
< ... calc correction ... > := freq / better estimation
;
That's somewhat like Tevet's idea:
@Article{tevet89,
author = "Adin Tevet",
title = "Symbolic Stack Addressing",
journal = jfar,
year = "1989",
volume = "5",
number = "3",
pages = "365--379",
url = "
http://soton.mpeforth.com/flag/jfar/vol5/no3/article2.pdf",
annote = "A local variable mechanism that uses the data stack
for storage. The variables are accessed by {\tt PICK}
and {\tt POST} (its opposite), which means that the
compiler must keep track of the stack depth. Includes
source code for 8086 F83."
}
However, I find that I don't need to decouple at the start *and* the
end. If I have a word with the stack effect ( a b c -- d e ), it's
usually straightforward to write it as:
: myword1 {: a b c -- d e :}
... compute d ... ( d )
... compute e ... ( d e ) ;
And if that is not possible, you can do it as follows:
: myword3 {: a b c -- d e :}
... compute e ... {: e :}
... compute d ... ( d ) e ;
or just
: myword2 {: a b c -- d e :}
... compute e ... ( e )
... compute d ... ( e d )
swap ;
Or if you really want to make the output explict, you could also write
it as follows:
: myword4 {: a b c -- d e :}
... compute e ... {: e :}
... compute d ... {: d :}
d e ;
And of course, there are also many cases where the data flow is simple
enough that using the stacks is sufficient.
- anton
-- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.htmlcomp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html New standard: https://forth-standard.org/EuroForth 2023 proceedings: http://www.euroforth.org/ef23/papers/EuroForth 2024 proceedings:
http://www.euroforth.org/ef24/papers/