🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6239

Re: Structured loops (WAS:Re: Turing programming language.)

#6239
From: s m ryan
Date: Thu, 26 Jan 1989 05:06
77 lines
2759 bytes
Dijkstra's loop is

	do guard -> statement
	|  guard -> statement
	| ...
	od

As long as at least one guard is true, execute a statement with a true guard.
If more than one guard is true, only one a statement is executed and it can
be any with a true guard. If no guard is true, the loop exits.

This loop does not permit an unconditional statement which is executed within
the loop before any guard, so Someone extended the construct

	do unconditional_statement
	|  guard -> statement
	|    . . .
	od

This loop cannot have an exit value and exit conditions are not explictly
specified, so Someoneelse extended the construct once more

	do unconditional_statement
	|  guard -> statement
	|   . . .
	|  guard -> expression exit
	|   . . .
	od

This loop executes the top statement and then selects a true guard. If no
guard is true Something Bad happens. If a guarded statement, the statement
is executed and the loop begins again. If a guarded expression exit, the
value of the loop is the value of the expression and the loop is exitted.

My contribution would be

	struct unconditional_statement
	|      guard -> statement again
	|      .  .  .
	|      guard -> expression exit
	|      .  .  .
	tcurts

which includes all the other structures:

	begin				struct skip
	  s				|      true -> s exit
	end				tcurts

	if p				struct skip
	 then s				|      p -> s exit
	 else t				|      not p -> t exit
	fi				tcurts

	if p -> s			struct skip
	|  q -> t			|      p -> s exit
	fi				|      q -> t exit
					tcurts

	while p				struct skip
	 do s od			|      p -> s again
					|      not p -> skip exit
					tcurts

	repeat s			struct s
	 until p			|      p -> skip again
					|      not p -> skip exit
					tcurts

My thought is to provide a single clause to the parser and then use macros
to make it pretty, rather than put all the complexity in a difficult to
change parser.
-- 
When it was caught, then Loki said,                                 -- s m ryan
`What fish is this from river's bed?
Your doom is near; to Hel you'll fly                           -- Andwari's Gem
unless with gold your life you buy.'                                    -- 1/10
Technical Details
Message-ID: <2472@garth.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!cmtl01!matrox!uvm-gen!uunet!ingr!garth!smryan
References: <11@euteal.UUCP> <89Jan20.111000est.4328@turing.toronto.edu> <12@euteal.UUCP> <7053@june.cs.washington.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!cmtl01!matrox!uvm-gen!uunet!ingr!garth!smryan
From: smryan@garth.UUCP (s m ryan)
Newsgroups: comp.lang.misc
Subject: Re: Structured loops (WAS:Re: Turing programming language.)
Summary: Other variations on a theme.
Message-ID: <2472@garth.UUCP>
Date: 26 Jan 89 05:06:22 GMT
References: <11@euteal.UUCP> <89Jan20.111000est.4328@turing.toronto.edu> <12@euteal.UUCP> <7053@june.cs.washington.edu>
Reply-To: smryan@garth.UUCP (s m ryan)
Organization: intergraph/apd in sunny california
Lines: 77