Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is Forth Everywhere?

199 views
Skip to first unread message

Mark Wills

unread,
Sep 21, 2017, 7:38:55 AM9/21/17
to
Maybe Forth is in *many* more things than we know about.

I use a massive SCADA system as part of my daily work, I won't
name the product, but it's one of the best, if not the very
best SCADA and Telemetry systems on the market.

It allows (among thousands of other things) logic to be written
in a language called Structured Text, which is part of the ANSI
61131 suite of languages for programmable controllers. It has
a similar feel to Pascal, and it may indeed be based on Pascal,
for all I know. It certainly "feels" like it. Anyway...

Here's some code that I wrote yesterday:

IF ( I_P1010 = Excluded ) OR ( RZ_Enabled = No ) THEN
P1 := P1 - 20 ;
END_IF ;

IF ( I_P1011 = Excluded ) OR ( RZ_Enabled = No ) THEN
P2 := P2 - 20 ;
END_IF ;

And here's what actually gets compiled:

IF postfix:[I_P1010 Excluded = RZ_Enabled No = OR] THEN
P1 := postfix:[P1 20 -];
END_IF;

IF postfix:[I_P1011 Excluded = RZ_Enabled No = OR] THEN
P2 := postfix:[P2 20 -];
END_IF;

Hmmm.... Now where have I seen that before? :-)

minf...@arcor.de

unread,
Sep 21, 2017, 9:50:36 AM9/21/17
to
IEC 61131-3 does not require the STL programming language to be transpiled
into a stack machine language.

For reference
https://en.wikipedia.org/wiki/Structured_text

Mark Wills

unread,
Sep 21, 2017, 10:08:12 AM9/21/17
to
I know. Most of them actually compile to IL, which is another 61131-3
language, and the IL is implemented as a VM.

However, in this particular case, there's clearly a stack machine underneath.

dxf...@gmail.com

unread,
Sep 21, 2017, 8:48:31 PM9/21/17
to
Well, there's a tendency to see 'forth'
everywhere :)

Versions of the XPL0 language
(www.xpl0.org) use a stack-based run-
time that looks and feels like classic
threaded code forth and does forth-like
tricks such as being able to compile
itself. On the outside it's a Pascal like
language. Conversions with one the
maintainers suggests forth wasn't an
influence despite XPL0 being developed
around the same time (mid 70's) and
some of its users avid 'forth nuts'.

invalid

unread,
Sep 23, 2017, 2:32:34 PM9/23/17
to
On 2017-09-21, Mark Wills <markwi...@gmail.com> wrote:
> On Thursday, 21 September 2017 14:50:36 UTC+1, minf...@arcor.de wrote:
>> Am Donnerstag, 21. September 2017 13:38:55 UTC+2 schrieb Mark Wills:
>> > Maybe Forth is in *many* more things than we know about.

It's been in HP Calculators for a long time. RPL, a FORTH-like language.

Great stuff!

(not RPN, which is older than RPL and possibly FORTH. RPL!)
0 new messages