Some PLANC Statements
PLANC is a language in the PASCAL family. However, it lacks the generic BEGIN END construct often found in PASCAL and favors instead forms like ROUTINE..ENDROUTINE or DO..ENDDO etc.
One feature that sets it apart from some other languages is the construction of loops:
DO .... loop statements... ENDDO
Hopefully one or more of the loop statements would be WHILE condition that allowed you to break out of the loop.
For example:
DO WHILE test ..... ENDDOIs similar to a C while (test) { ... } loop.
Another example:
DO ...... WHILE testENDDO
Is similar to a C do { .... } while (test). loop.
Sometimes programmers wrote:
DO WHILE test1 ..... WHILE test2 ENDDOIn C you would have to write something like while (test1) { .... if (! test2) break; } or some such.
For loops have the following structure:
FOR var IN low:high DO .... loop statements.... ENDDO
You can also specify a step by low:high:step. Alternatively you can specify a type (enumeration or integer ranged type) to specify a loop over a range of values or a set to loop over all elements of the set or you can specify an array to loop over an array. You can also specify a pointer:next to walk through a list. For example if defining:
TYPE node = RECORD node POINTER : next T : some_data ENDRECORDYou could write:
FOR p IN first:next DO ..... ENDFOR
to loop over the list.
A for loop can have WHILE statements inside it. This provides two possible manners of exiting a for loop, either because the list of values are exhausted or because the test failed. Thus, you can write blocks to catch each of those:
routine void,node pointer (node pointer : list) for p in first:next do while p.val >< 20 exitfor return nil endfor return endroutineThis returns nil if you have exhausted the list but if you exited due to while you just ended up after the loop and returned the pointer to the element found. Alternatively you could have placed that in an exitwhile block which is identical except you would end up there if and only if the while test failed. If you have more than one while statement in the loop you could not tell those apart, they would all make a jump to the same exitwhile block.
PLANC had a primitive exception mechanism - a routine could return an exception, which was a 16-bit integer value. This could then be caught by an ON ROUTINEERROR statement in the calling scope.
Read more about this topic: PLANC
Famous quotes containing the word statements:
“We assume that politicians are without honor. We read their statements trying to crack the code. The scandals of their politics: not so much that men in high places lie, only that they do so with such indifference, so endlessly, still expecting to be believed. We are accustomed to the contempt inherent in the political lie.”
—Adrienne Rich (b. 1929)