Dijkstra Control Structures 
Author Message
 Dijkstra Control Structures

The preliminary version of my implementation of the Dijkstra guarded
command control structures is ready and posted on my Web page.  I have
some kind of obscure HTML bug that I need to track down, but the links
all seem to work and the code looks OK.  The URL is

http://www.*-*-*.com/ ~znmeb/discp/discp.htm

Please feel free to e-mail comments, or to post them here.

--

"I'm not a saxophone, but I play one on TV!" -- Bill Clinton



Fri, 22 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures

Hey, I did this once.  Gave a report at FORML in 1983?  I'll have to look
at your page and compare notation.

Charlie Springer



Fri, 22 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures

: Hey, I did this once.  Gave a report at FORML in 1983?  I'll have to look
: at your page and compare notation.

: Charlie Springer

I was hoping someone had already done it.  There's probably not much
difference except mine is designed for ANS Forth.

--

I support the right to keep and arm bears.



Fri, 22 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures

Here is a guarded command implementation originally done by John
Reigsecker of the University of Puget Sound.  This is basically FIG FORTH
or MVPFORTH.  In the GUARDS vocabulary the 'IF' replaces the regular Forth
'IF' since the guarded commands are a complete set of control structures.
I used to talk these up all the time, but nobody ever showed any interest
to speak of.

Charlie Springer

VOCABULARY GUARDS IMMEDIATE
GUARDS DEFINITIONS

: --> [COMPILE] IF ; IMMEDIATE

: IF -1 ; IMMEDIATE

: [] COMPILE 0 [COMPILE] ELSE ; IMMEDIATE

: FI [COMPILE] [] COMPILE 1
     BEGIN [COMPILE] ENDIF DUP -1 = UNTIL
     DROP COMPILE DROP ; IMMEDIATE

: DO [COMPILE] BEGIN -2 ; IMMEDIATE

: OD [COMPILE] [] COMPILE 1
     BEGIN [COMPILE] ENDIF DUP -2 = UNTIL
     DROP [COMPILE] UNTIL ; IMMEDIATE

FORTH DEFINITIONS

( Euclid with an IF ... FI )

: EUCLID1  ( n1, n2 ---, GCD )
    GUARDS
    DO OVER OVER - 0= NOT -->
       IF OVER OVER >  -->  SWAP OVER - SWAP
       [] OVER OVER <  -->  OVER -
       FI
    OD
  DROP ;
FORTH

( Euclid with a DO ... OD )
: EUCLID2 ( n1,n2 --, GCD )
    GUARDS
    DO OVER OVER >  --> SWAP OVER - SWAP
      [] OVER OVER <  --> OVER -
    OD
  DROP ;
FORTH

( The Guared Commands allow a very simple Case )

: CASE -2 ; immediate

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

:  :: [COMPILE] ELSE ; IMMEDIATE

: ENDCASE BEGIN [COMPILE] ENDIF DUP -2 = UNTIL DROP ; IMMEDIATE

: OTHERWISE COMPILE DUP ; IMMEDIATE

: SKIP ;

( Case example )
: TestCase ( n ---, )
    CASE  5  ==>  ." 5 case "
     ::   2      ==>  ." 2 case "
     ::   9      ==>  ." 9 case "
     ::   3      ==>  ." 3 case "
     :: OTHERWISE ==> ." No case "
    ENDCASE ;



Sat, 23 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures


Quote:
>> Here is a guarded command implementation originally done by John
>> Reigsecker of the University of Puget Sound.  This is basically FIG
FORTH
>> or MVPFORTH.  In the GUARDS vocabulary the 'IF' replaces the regular
Forth
>> 'IF' since the guarded commands are a complete set of control
structures.

>Excuse me.

>This is not Dijkstra's guarded commands.

>With guarded commands, selection of alternatives is non-determinate
>when guards are not exclusive*.  The empty guard OTHERWISE "None
>of the above" always yields ABORT in "if ... fi".
>* The examples are all exclusive but the implementation doesn't
>provide for anything else.

You jog my memory.  I remember we talked about making the structures
non-deterministic but did not have any programming examples that could
benefit from it or justify the overhead.  This was over ten years ago on 1
and 2 MHz 6502s, so we worried over every bit of speed.  Was the
non-determinism needed for the proofs of correctness?

Quote:
>: EUCLID BEGIN ?DUP WHILE TUCK MOD REPEAT ;   ( m n -- gcd )

I assume TUCK is an ANSI Forth word?  I (like many) have not used any ANSI
or have used it as if it is 79 or 83 or whatever the Standards Club most
recently foisted on the unsuspecting market place.

Quote:
>It would be more productive to extend Forth control-flow with a
>form commandeered from Scheme/Lisp.

Is anyone doing any productive work in Forth?  I still can't talk anyone
into letting me use it even though, as we all know, I could save them a
lot of time and money.  The project I am working on right now is ideal and
the company only has two programmers.  But I get the usual "where will we
find Forth programmers if you leave".

Charlie Springer



Sun, 24 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures

I've been wondering if Nick Solntseff is going to chime in.
He presented an interesting paper on related to this topic
at Southern Ontario FIG about two years ago.




Sun, 24 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures

Quote:
>Is anyone doing any productive work in Forth?  I still can't talk anyone
into  
>letting me use it even though, as we all know, I could save them a lot of
time  
>and money.  The project I am working on right now is ideal and the company
only  
>has two programmers.  But I get the usual "where will we find Forth
programmers  
>if you leave".

>Charlie Springer

Hi.. I am a consultant and FORTH is my preferred language.  I just did a
project on a HC11 for a company where I was in and out of there in less
than a month.  
I used a Mosaic Industries QED board with many good tools to make the job a
pleasure.
Now, at another company, I am starting a C project on a HC16. It looks like
6 months minimum. To late to switch them since they have alot of C code
written but poorly organized. The new board is a custom design and I have
to duplicate the RTX tools that were present on the HC11.  I am buying a
commercial package that has been ported to many different processors.

Why can't a group in the FORTH community offer a transportable tool kit for
a variety of platforms?  I suppose the closest I have seen is the ChipFORTH
from FORTH, Inc.  What else is out there?

--
Virgil Stamps  "Give the World a smile each day"
SACO Electronic Products. Specialist in real-time:  PolyForth, C, Assembly,
PIC, RTX-2000



Sun, 24 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures


: >> Here is a guarded command implementation originally done by John
: >> Reigsecker of the University of Puget Sound.  This is basically FIG
: FORTH
: >> or MVPFORTH.  In the GUARDS vocabulary the 'IF' replaces the regular
: Forth
: >> 'IF' since the guarded commands are a complete set of control
: structures.
: >
: >Excuse me.
: >
: >This is not Dijkstra's guarded commands.
: >
: >With guarded commands, selection of alternatives is non-determinate
: >when guards are not exclusive*.  The empty guard OTHERWISE "None
: >of the above" always yields ABORT in "if ... fi".

Yes, I noted this in my implementation.  The Occam implementation is the
only one I know of that used the nondeterministic form.  Per Brinch
Hansen's Edison used what I call the sequential version:  test the
guards in the order written and do the code associated with the first
true one found.  This is what I implemented.

: >* The examples are all exclusive but the implementation doesn't
: >provide for anything else.

: You jog my memory.  I remember we talked about making the structures
: non-deterministic but did not have any programming examples that could
: benefit from it or justify the overhead.  This was over ten years ago on 1
: and 2 MHz 6502s, so we worried over every bit of speed.  Was the
: non-determinism needed for the proofs of correctness?

I don't think so.  Dijkstra was fairly proud of the fact that his
formalism *allowed* nondeterministic programs to be proved correct, but
he didn't insist that implementations had to be nondeterministic.

That was actually going to be my next step -- to try to implement the
nondeterministic form using the hForth multitasker.

: >: EUCLID BEGIN ?DUP WHILE TUCK MOD REPEAT ;   ( m n -- gcd )

: I assume TUCK is an ANSI Forth word?  I (like many) have not used any ANSI
: or have used it as if it is 79 or 83 or whatever the Standards Club most
: recently foisted on the unsuspecting market place.

TUCK is not a CORE word; it's in one of the extension word sets.  But it
can be defined using only CORE words.

: >It would be more productive to extend Forth control-flow with a
: >form commandeered from Scheme/Lisp.

I've come to the conclusion (Wil Baden, jump in and bail me out :-) that
Forth is close to reverse-Polish Scheme anyway.

: Is anyone doing any productive work in Forth?  I still can't talk anyone
: into letting me use it even though, as we all know, I could save them a
: lot of time and money.  The project I am working on right now is ideal and
: the company only has two programmers.  But I get the usual "where will we
: find Forth programmers if you leave".

Forth, Inc., MPE and a number of other organizations are indeed doing
productive work in Forth.  There are Forth jobs posted on FIG's bulletin
boards.  I think you do need a certain critical mass, though -- it takes
a company with the marketing clout of Forth, Inc. or LMI or MPE to sell
a Forth project -- two programmers in a company can't do it.
--

Actually, for their size, elephants don't smell all that bad.

"The only thing we have to fear is fear itself -- and, of course, the
boogeyman."  Pat Paulsen



Sun, 24 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures

[...]

Quote:
>Is anyone doing any productive work in Forth?  I still can't talk anyone
>into letting me use it even though, as we all know, I could save them a
>lot of time and money.  The project I am working on right now is ideal >and the company only has two programmers.  But I get the us=

ual "where >will we find Forth programmers if you leave".

Quote:

>Charlie Springer

I could hardly believe my ears when my employer allowed me to use Forth
on our current project(s).  Forth is plenty productive and the best tool
for the job, even though the Forths I see today are far behind where I
think Forth systems could be.  Perhaps you could get approval to use
Forth on a small, peripheral project.  Your success could lead to Forth
use on other projects, until management gets comfortable with the idea of
making a major commitment to Forth.

-- Brad



Tue, 26 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures

Quote:

> >Is anyone doing any productive work in Forth?  I still can't talk anyone
> into
> >letting me use it even though, as we all know, I could save them a lot of
> time
> >and money.  The project I am working on right now is ideal and the company
> only
> >has two programmers.  But I get the usual "where will we find Forth
> programmers
> >if you leave".

> >Charlie Springer

Charlie, perhaps this should inspire we who love Forth to create as many local chapters of FIG as
possible. Then we can grow a good crop of them. I'm working with the management at my company to
start a St. Louis chapter...we should be up and having our first meeting by October, 1996.

Quote:
> Hi.. I am a consultant and FORTH is my preferred language.  I just did a
> project on a HC11 for a company where I was in and out of there in less
> than a month.
> I used a Mosaic Industries QED board with many good tools to make the job a
> pleasure.
> Now, at another company, I am starting a C project on a HC16. It looks like
> 6 months minimum. To late to switch them since they have alot of C code
> written but poorly organized. The new board is a custom design and I have
> to duplicate the RTX tools that were present on the HC11.  I am buying a
> commercial package that has been ported to many different processors.

> Why can't a group in the FORTH community offer a transportable tool kit for
> a variety of platforms?  I suppose the closest I have seen is the ChipFORTH
> from FORTH, Inc.  What else is out there?

For my 2 cents, I think a great "trend" to jump on is the Microsoft Windows-NT/95 bandwagon. It's
already a big hit among many large companies, and I happen to like Win32For a lot for development. I
have management approval, Tom & Andrew's fine product powers our website right now, and I see
nothing but good times ahead in the area of Windows-NT/95 and Win32for.

One "tip" I can offer however, with using their package...don't change it at all...just add your own
embelishments in source code files that are "appended" to Win32for. So far, after using the product
for roughly two years, I've never seen them introduce a version that I couldn't recompile my add-ons
to without the greatest of ease.

Of course, this isn't the "transportable tool kit" that you mentioned, but I'll put my betting money
on Microsoft Windows NT taking over corporate America (i.e. $$$$), and I like the ease with which I
can produce quality software on NT with Win32for.

Quote:
> --
> Virgil Stamps  "Give the World a smile each day"
> SACO Electronic Products. Specialist in real-time:  PolyForth, C, Assembly,
> PIC, RTX-2000

:-)   (How's that!)

- Bill <grin>

--
                 \\\|///
                \\ ~ ~ //

--------------oOOo-(_)-oOOo---------------------------
William B. Zimmerly (Bill) -
Systems Research & Development Manager / Webmaster
General American Life Insurance Company, Inc.
Amateur Radio Call: KA0YKO

Home Page Address:  www.inlink.com/~billz
~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._



Tue, 26 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures

Quote:

> I've come to the conclusion (Wil Baden, jump in and bail me
> out :-) that Forth is close to reverse-Polish Scheme anyway.

That was my first impression of Forth.

There are definite similarities but also great differences.  Phil
Koopman's book on Stack Architecture is the best reference.



Thu, 28 Jan 1999 03:00:00 GMT  
 Dijkstra Control Structures

On Aug 09, 1996 14:30:11 in article <Re: Dijkstra Control Structures>,

Quote:


>For my 2 cents, I think a great "trend" to jump on is the Microsoft  
>Windows-NT/95 bandwagon. It's already a big hit among many large
companies, and  
>I happen to like Win32For a lot for development. I have management
approval,  
>Tom & Andrew's fine product powers our website right now, and I see
nothing but  
>good times ahead in the area of Windows-NT/95 and Win32for.

>One "tip" I can offer however, with using their package...don't change it
at  
>all...just add your own embelishments in source code files that are
"appended"  
>to Win32for. So far, after using the product for roughly two years, I've
never  
>seen them introduce a version that I couldn't recompile my add-ons to
without  
>the greatest of ease.

>Of course, this isn't the "transportable tool kit" that you mentioned, but
I'll  
>put my betting money on Microsoft Windows NT taking over corporate America
>(i.e. $$$$), and I like the ease with which I can produce quality software
on  
>NT with Win32for.

>:-)   (How's that!)

>- Bill <grin>

>--  
>\\\|///
>\\ ~ ~ //

>--------------oOOo-(_)-oOOo---------------------------
>William B. Zimmerly (Bill) -
>Systems Research & Development Manager / Webmaster
>General American Life Insurance Company, Inc.
>Amateur Radio Call: KA0YKO

>Home Page Address:  www.inlink.com/~billz
>~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._

--
Good thoughts Bill.  I have been a user of polyFORTH for years but....
I am afraid competing against the MS giant makes you a weak me too, no
matter how good your tools are.  You need to establish a nitch market.
With the continuing proliferation of microprocessors, there is always the
need to port development tools to them.  Why not port ANSI FORTH kernals
chock full of well-defined tools taking advantage of resident hardware (A/D
QSPI, SPI, SCI, EEPROM interface to 3-wire devices for example).
--
Virgil Stamps  "Give the World a smile each day"
SACO Electronic Products. Specialist in real-time:  PolyForth, C, Assembly,
PIC, RTX-2000


Thu, 28 Jan 1999 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Control Structure Question

2. More control structures

3. Proposal for control structures in APL

4. Proposal for control structures in APL

5. Proposal for control structures in APL (SAMSON)

6. Control Structures in APL

7. Control Structures in APL

8. Control structures in APL

9. APL Control Structures

10. Control structures.

11. Control structures in APL

12. Control structures; discussion or proposal

 

 
Powered by phpBB® Forum Software