🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

4 total messages Started by Harold Carr Fri, 14 Sep 1984 18:40
dynamic constants
#128
Author: Harold Carr
Date: Fri, 14 Sep 1984 18:40
23 lines
1089 bytes

I am new to forth.  Could someone tell me how to do this
in Princeton's VaxForth?:

When loading a file that contains:

8 len data

I want 8 to be pushed (as it will be) and LEN to be defined
such that it has the effect:

here constant data allot  ( with allot getting its parameter)
                          ( from the previous push of 8)

In other words, I want to dynamically create a constant whose name
is taken from the input stream.

Any help would be much appreciated.

Harold Carr    
arpa: CARR@UTAH-20
uucp: harpo!utah-cs!carr
Speaking of Princeton
#130
Author: Keith Doyle
Date: Mon, 17 Sep 1984 18:01
23 lines
1562 bytes
While the recent distribution of Princeton FORTH is still fresh
on our computers, I've been evolving a list of "how do you do it"'s
and was wondering if any of you out there have had similar problems/
successes:

1. How do I implement the equivalent of ?TERMINAL  ?

2. How can I implement my own control structures ( such as Charles Eaker's
   CASE statement ) without resorting to otherwise unknown assembly language?

3. Is it absolutely impossible (under UNIX or on a VAX) to implement the
   capability to re-save FORTH after an application has been compiled?
   (useful when writing canned applications invoked from the O.S. - there's
   no need for some users to know what language it was written in, and
   there's little need to wait for your editor to compile EVERY time you
   enter FORTH )

Except for these problems, I find Princeton FORTH an excellent version,
and FAST!.

Keith Doyle
{ucbvax,decvax}!trwrb!cadovax!keithd
Re: Speaking of Princeton
#135
Author: William L. Sebok
Date: Thu, 20 Sep 1984 21:29
56 lines
3165 bytes
As my subscription to Forth Dimensions has lapsed I may be somewhat behind on
what is current in forth.  Also I haven't myself directly had to deal with
a FigForth system.  My first forth system was a Forth Inc. system circa 1976,
which predated FigForth.  From after many of my own changes I went directly to 
Forth 79.

> While the recent distribution of Princeton FORTH is still fresh
> on our computers, I've been evolving a list of "how do you do it"'s
> and was wondering if any of you out there have had similar problems/
> successes:
> 
> 1. How do I implement the equivalent of ?TERMINAL  ?

Sorry, but what does ?TERMINAL do?

> 2. How can I implement my own control structures ( such as Charles Eaker's
>    CASE statement ) without resorting to otherwise unknown assembly language?

Again, could you define Charles Eaker's CASE statement? If a control structure
needs no more of the underlying architecture than conditional branches you
could define immediate words that contain (from the ASSEMBLER vocabulary):
COMPILE IF ,  COMPILE THEN ,  and COMPILE UNTIL  and COMPILE whatever else you
need.

	addr cond UNTIL		compiles an arbitrary conditional branch from
				HERE to addr.

	cond IF	 --- addr	compiles an uncompleted forward conditional
				branch from HERE (using a conditional branch
				around a two-byte-displacement unconditional
				branch).

	addr THEN		completes an IF. addr is the address returned
				by the IF.  The destination is HERE.

I had included a CASE statement but I am not sure if is identical to the
one you want.  If you send me the definition I will try to implement it.

> 3. Is it absolutely impossible (under UNIX or on a VAX) to implement the
>    capability to re-save FORTH after an application has been compiled?
>    (useful when writing canned applications invoked from the O.S. - there's
>    no need for some users to know what language it was written in, and
>    there's little need to wait for your editor to compile EVERY time you
>    enter FORTH )

No, its not impossible. I am working on it and the next version will contain
it.  I am also working on loading non-Forth subroutine as Forth words.

There is much more that can be added to Forth, limited only by my time to
work on it.

It looks like I might have accomplished one of the things I hoped by posting
Forth: to stir up some life in this otherwise rather dead newsgroup.
-- 
Bill Sebok			Princeton University, Astrophysics
{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls
Re: Speaking of Princeton
#138
Author: William L. Sebok
Date: Sat, 29 Sep 1984 00:59
59 lines
2737 bytes
Here are a few answers to a couple of recent questions.  These words have
been tested on the Forth at astrovax.

> While the recent distribution of Princeton FORTH is still fresh
> on our computers, I've been evolving a list of "how do you do it"'s
> and was wondering if any of you out there have had similar problems/
> successes:
> 
> 1. How do I implement the equivalent of ?TERMINAL  ?

A definition for ?TERMINAL (called KEY? in Forth 83) in Princeton Forth under
either BSD 4.2 or 4.1 would be:

HEX
find 4.2BSD #if  4004667f  #else 667F #then  CONSTANT FIONREAD
DECIMAL

VARIABLE NBYTES

: ?TERMINAL  NBYTES FIONREAD TYPER @ A1+ @ $IOCTL ?UERROR  DROP
 NBYTES @ ;

This returns the number of characters waiting to be input.  Ordinarily it only
knows about full lines of characters.  However when the terminal is in raw
mode (set by <KEY and KEY> ) it knows about individual characters.  Beware
that both <KEY and KEY> flush input, i.e. forget all pending input characters.
This is known as living with what Unix provides.  The next version of my vax
forth is likely to have ordinary input in CBREAK mode (to provide extra
interactive features) so it may not have those restrictions.

> 2. How can I implement my own control structures ( such as Charles Eaker's
>    CASE statement ) without resorting to otherwise unknown assembly language?

A version of the CASE you requested would be:

VARIABLE CSP

: OF  COMPILE OVER  COMPILE =  [COMPILE] IF  COMPILE DROP ;
 IMMEDIATE

: CASE  'S CSP ! ; IMMEDIATE

: ENDOF  [COMPILE] ELSE ; IMMEDIATE

: ENDCASE  COMPILE DROP
 BEGIN  'S CSP @ <> WHILE  [COMPILE] THEN  REPEAT ; IMMEDIATE

Alternatively OF could be

: OF  [COMPILE] CASE ; IMMEDIATE

using the old CASE, which does the same thing as OF should do.

This has no compile time testing.  I should consider adding some of that to
this implementation.  Right now this implementation shows its Forth Inc. forth
ancestry and little or no compile time checking.
-- 
Bill Sebok			Princeton University, Astrophysics
{allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads