[comp.lang.forth] HP 48SX uses Forth?

us048503@mmm.serc.3m.com (Art H. Hurst) (06/10/91)

The latest HP Journal (June 1991) sports a front page picture of the new
HP 48SX showing a routine written in what looks very much like Forth.
The text says " The fundamental basis of the HP 48SX system is the RPL
operating system, which occupies about 18K bytes of the system ROM. This
system first appeared in the HP 18C Business Consultant calculator in
1986. In brief, the system combines elements of Forth and Lisp
providing a multi-object RPN stack and direct and indirect threaded
execution, with both atomic and composite objects, temporary (lambda)
variables, and the ability to pass unevaluated procedures as arguments.
The objects are similar to Forth words, containing the address of the
executable code that defines the object and the data that makes up the
body of the object.

"In this issue" describes what we see on the front page as an example of
EquationWriter which is not discussed in any detail in the issue. The
following is what is shown:

@Program to compute a list of prime numbers
<< 7 -> x
   << { 2 3 5 }
      1 SF
      DO
	2 SF
	3
	DO
	GETI x OVER /
	UNTIL
	   IF SWAP OVER >
	     DUP
        THEN SWAP DROP
	ELSE
	  SWAP
	  IF FP NOT
	  THEN 2 CF NOT


That is the end of the screen on the illustration. Does anyone have any
info on this? Seems as though Forth is still alive deep within HP.


Art Hurst
ahhurst@3m.com

cbbrowne@csi.uottawa.ca (Christopher Browne (055908)) (06/11/91)

In article <1991Jun10.142047.20295@mmm.serc.3m.com> ahhurst.3m.com (Art H. Hurst) writes:
>..... In brief, the system combines elements of Forth and Lisp
>providing a multi-object RPN stack and direct and indirect threaded
>execution, with both atomic and composite objects, temporary (lambda)
>variables, and the ability to pass unevaluated procedures as arguments.
>The objects are similar to Forth words, containing the address of the
>executable code that defines the object and the data that makes up the
>body of the object.

Code Deleted...

>That is the end of the screen on the illustration. Does anyone have any
>info on this? Seems as though Forth is still alive deep within HP.

DEFINITELY Forth is still alive at HP...  They don't CALL it Forth;
they have added features that would make most traditional Forthers
SHUDDER (Floating point?!?!?!  How DARE they! :-)).  The 28 & 48 series
both use (horrors!) an automagic dynamic memory allocation system that's
used for everything from strings to variables to WORDS (functions?)  ALL
of which are dealt with as "objects" that are treated equally.  Parameters
are passed on an explicit stack; that stack does NOT contain integer cells
but rather pointers to objects.

It's NOT the classic  small Forth we know and love - it's Forth with the
(somewhat less tight speed+memory-wise) features of the '90s.  When I
think about the features I'd like to add to my system, I take a look at
my calculator...

Here's a thought;  
In RPL, the IF/THEN/ENDIF thing works as follows:

	IF     code-adding-flag
	THEN
		true-code
	ELSE    (which is optional)
		false-code
	ENDIF

This corresponds to (in traditional Forth)
	code-adding-flag
	IF      true-code
	ELSE    false-code
	THEN

One of my pet peeves is the word THEN; it IS mnemonic, but the useage is
different from the usage of THEN in virtually ALL other computer languages,
and it is different from the typical useage of the word "THEN" in English:

"If I have $50, THEN I will pay the shareware fee"

I wouldn't mind changing the meaning of the FORTH words around to agree with
the way RPL does it;

: new-IF                  ; immediate   \ does NOTHING - just looks good...
: new-THEN [COMPILE] IF   ; immediate \ does what IF used to do...
: new-ELSE [COMPILE] ELSE ; immediate \ No change...  Else DOES do the right
                                      \ thing...
: new-ENDIF [COMPILE] THEN ; immediate

I doubt that the standards committee would be into changing the language
around like this; but it's the way I would code it...  No sense in having
the language use conventions different than everyone else (outside the
Forth world) uses.

I'm open to argument as to where stack arguments should go; BEFORE the IF
or AFTER; in RPL, BOTH places are pretty valid.

-- 
Christopher Browne
cbbrowne@csi.uottawa.ca
University of Ottawa
Master of System Science Program

RAYBRO%HOLON%UTRC@UTRCGW.UTC.COM ("William R Brohinsky", ay) (06/11/91)

Christopher Browne writes:
>different from the typical useage of the word "THEN" in English:
>"If I have $50, THEN I will pay the shareware fee"

Different `typical' English dialects reign in different parts of the
world. (This is not to be construed as a slur on Canadien English:
I grew up in Plattsburgh, and there's a lot more people who don't speak
English very well on the southern side of that border!)

In some places in the USA, I've heard:

"Lessee, I got $50? Good: I can pay the Shareware, then"

Maybe this is the sort of thing Charles Moore had to listen to when
he was formulating FORTH?

For what it's worth, it is quite common to rename THEN to END-IF.
Just remember to make it fairly obvious in your code that this is what
you are doing.

I remember that THEN and END-IF were equivalent in some early versions
of forth, including, if I remember, the distributed fig-forth model.

raybro

ttobler@unislc.uucp (Trent Tobler) (06/18/91)

>different from the typical useage of the word "THEN" in English:
>"If I have $50, THEN I will pay the shareware fee"

"IF I have $50, I will pay the shareware fee, otherwise (ELSE) I will
look for a public domain program.  THEN I will use my computer."

I see no conflict with English with this method.

Of course, forth, being RPN, would be  "Have I $50 if ..."   :-)

--
  Trent Tobler - ttobler@csulx.weber.edu

jeffj@mcs213k.cs.umr.edu (Jeff Jenness) (06/19/91)

In article <1991Jun17.212641.28529@unislc.uucp> ttobler@unislc.uucp (Trent Tobler) writes:
>
>"IF I have $50, I will pay the shareware fee, otherwise (ELSE) I will
>look for a public domain program.  THEN I will use my computer."
>
>I see no conflict with English with this method.
>

To be exact the above sentence has an implied 'then' after the first comma
and the second 'then' is related to the sequence of the events in time and
not related logically with the 'if' in first sentence.  The sentence should
read:

"IF I have $50 THEN I will pay the shareware fee, ELSE I will look
for a public domain program.  AFTER WHICH I will use my computer."

I am not sure that you can construct an if-then-else sentence in the way
you wish in proper English (it sounds awkward), but you could probably get
away with it.

-- 
Jeff Jenness
University of Missouri - Rolla
jeffj@cs.umr.edu