[comp.lang.forth] BASIS

wmb@MITCH.ENG.SUN.COM (08/21/90)

>    Suggestion: The ANSI team make available a packet consisting of
>    the printed BASIS document and a diskette with the document in
>    machine-readible form (preferably including a plain ASCII text
>    glossary file).  THIS SHOULD BE AVAILABLE IN A TIMELY FASHION SO
>    THAT USERS HAVE AMPLE TIME TO PREPARE SUBMISSIONS TO THE ANSI
>    TEAM.

Agreed in principle.  In practice, it is a bit difficult.

1) The volunteer editor is already doing a heroic job in getting the
   Basis out as soon as it is getting out.

2) As we have seen, everybody appears to want a different machine-readable
   format.

> II. Deferred Execution
>     Will the proposed ANSI standard have a portable mechanism for
>     deferred execution (like the F83 words  DEFER and IS)

: DEFER  CREATE 0 ,  DOES> @ EXECUTE  ;
: SET-DEFER  ( cfa cfa -- )  >BODY !  ;

> III. Recursion and return stack size
>     When implementing a recursive algorithm it often becomes necessary
>     to increase the size of the return stack. Will there be a portable
>     way to do this?

No.

>    Along the same lines:  will there be words analogous to RP0, SP0,
>    RP@, SP@?

No.  The data stack and the return stack are not guaranteed to be addressable
with @ and ! .  To guarantee that would eliminate most Forth chips.

>          : IF(  0  >R     \ count the number of IFs used
>                BEGIN     ' DUP  ['] )IF  <>
>                WHILE     , [COMPILE] IF
>                        ' , [COMPILE] ELSE
>                        R> 1+ >R
>                REPEAT   DROP
>                R> 0 DO  [COMPILE] THEN  LOOP  ;  IMMEDIATE
>
>          How would this be rewritten to comply with the proposed ANSI
>          Standards?

           : IF(  0  >R     \ count the number of IFs used
                 BEGIN     ' DUP  ['] )IF  <>
                 WHILE     COMPILE-TOKEN POSTPONE IF
                         ' COMPILE-TOKEN POSTPONE ELSE
                         R> 1+ >R
                 REPEAT   DROP
                 R> 0 DO  POSTPONE THEN  LOOP  ;  IMMEDIATE

Unfortunately, this depends on the word COMPILE-TOKEN , which has been
proposed but which has not passed.  However, you could do it as follows:

           : IF(  0  >R     \ count the number of IFs used
                 BEGIN     BL WORD DUP COUNT  " )IF"  $=  <>
                 WHILE     COUNT EVALUATE        POSTPONE IF
                         BL WORD COUNT EVALUATE  POSTPONE ELSE
                         R> 1+ >R
                 REPEAT   DROP
                 R> 0 DO  POSTPONE THEN  LOOP  ;  IMMEDIATE

The implementation of $= , which compares two "adr len" strings,
is left to the reader as an exercise.

>    Far more significant than the controversy over certain proposed
>    words are the circulating rumors that some members of the ANSI
>    Team do not expect it to be possible to write significant programs
>    using only proposed words and programming practices.

As a member of the team, I do not share this belief.  Of course, it depends
upon your definition of "significant".  There are some classes of programs
that it may not be possible to write using only standard words, but I would
claim that those classes do not represent a large fraction of "all significant
programs".

>    Is the ANSI team willing to provide clarification, at this point,
>    as to whether or not a purpose of the proposed Standard is to
>    allow users to write significant programs portably?

I believe that this is indeed an important goal.  It certainly is for me.
Based upon my experience in committee, I would go out on a limb and say that
it is important to most other committee members too.

But, I reiterate, it depends on what you mean by "significant".  It is always
possible to say (and I have heard it said all too often):

	I can't figure out how to write program "x", therefore it is not
	possible to write significant programs.

There will be some programs which you can only write if you know
implementation details.  By and large, this is the state of the world
with current Forth systems, and ANS Forth won't wave a magic wand
and make those programs portable.  But it will extend the domain of
portablility into some important new areas, such as files and floating
point.  And it will also more clearly define the limits of portability
in certain existing problem areas, such as the assumptions you can make
about the behavior of HERE , CREATE , and ALLOT .

Mitch

dwp@willett.pgh.pa.us (Doug Philips) (08/24/90)

In <9008230622.AA29039@ucbvax.Berkeley.EDU>, wmb@MITCH.ENG.SUN.COM writes:
> 2) As we have seen, everybody appears to want a different machine-readable
>    format.

Sigh.  Maybe by the time the BASIS series is done and the draft proprosals
are started we could work something out?  Personally, I don't want an
on-line copy so that I can print it myself, or see it in nice fancy
graphics on my screen.  I want an on-line copy so I can search it, index
it, etc...

> point.  And it will also more clearly define the limits of portability
> in certain existing problem areas, such as the assumptions you can make
> about the behavior of HERE , CREATE , and ALLOT .

I think this is one of the most important things the ANSI effort will do.

-Doug

---
Preferred: ( dwp@willett.pgh.pa.us  OR  ...!{sei,pitt}!willett!dwp )
Daily: ...!{uunet,nfsun}!willett!dwp  [last resort: dwp@vega.fac.cs.cmu.edu]


---
Preferred: ( dwp@willett.pgh.pa.us  OR  ...!{sei,pitt}!willett!dwp )
Daily: ...!{uunet,nfsun}!willett!dwp  [last resort: dwp@vega.fac.cs.cmu.edu]