PLANC: Difference between revisions

From NDWiki
Jump to navigation Jump to search
m (Typo: Laguage -> Language)
(→‎Product number: added ND-211038)
 
(9 intermediate revisions by 2 users not shown)
Line 3: Line 3:
Compilers were developed by [[Norsk Data]] for several architectures, including the [[wikipedia:Motorola 68000|Motorola 68000]], [[wikipedia:Motorola 88000|88000]], [[wikipedia:x86|x86]], and the Norsk Data [[NORD-10]] architecture and [[ND-500]] [[wikipedia:Superminicomputer|supermini]].
Compilers were developed by [[Norsk Data]] for several architectures, including the [[wikipedia:Motorola 68000|Motorola 68000]], [[wikipedia:Motorola 88000|88000]], [[wikipedia:x86|x86]], and the Norsk Data [[NORD-10]] architecture and [[ND-500]] [[wikipedia:Superminicomputer|supermini]].


It was mainly used internally at ND for writing high level systems software such as the upper parts of the operating systems and compilers. It was designed to be platform independent.
The language was designed to be platform independent. It was mainly used internally at Norsk Data for writing high level systems software such as the upper parts of the operating systems and compilers.


== PLANC basic structure ==
== PLANC basic structure ==


PLANC programs are structured into modules and routines.
'''PLANC''' programs are structured into modules and routines.


A very simple example of a PLANC program is as follows:
A very simple example of a '''PLANC''' program is as follows:


  MODULE mod
  MODULE mod
Line 22: Line 22:
  ENDMODULE
  ENDMODULE


The most visible difference from other popular programming languages is that the assignment operator goes from left to right: First you compute the value, then you store it. The assignment operator also returns the stored value, so you could store it multiple times: 5 =: a =: b would store 5 into both the A and B variables. It shares this direction with [[wikipedia:Mary (programming language)|Mary]], another little known programming language developed in Norway.
A difference from popular programming languages is that the assignment operator goes from left to right: First you compute the value, then you store it. Compile-time initialization of variables, on the other hand, went from right to left.  


Compile-time initialization of variables, on the other hand, went from right to left.
The assignment operator returns the stored value, so you could store it multiple times: 5 =: a =: b would store 5 into both the A and B variables. It shares this direction with [[wikipedia:Plankalkül|Plankalkül]], early [[wikipedia:ALGOL|ALGOL]] drafts, and [[wikipedia:Mary (programming language)|Mary]], another little known programming language developed in Norway, but also the popular C programming language.
 
A related distinct syntactic feature is that a function can be defined to take as input the computed value of the expression on its left side. Also, a single additional argument does not require surrounding parentheses. The resulting [[wikipedia:infix notation|infix notation]] blurs the syntactical difference between functions and [[wikipedia:Operator (programming)|operators]]. Such expressions seem conceptually as having a computed value flowing from left to the right.


==PLANC data types==
==PLANC data types==
Line 55: Line 57:
== Some PLANC statements ==
== Some PLANC statements ==


PLANC was a language in the PASCAL family. However, it lacked the generic BEGIN END construct often found in PASCAL and preferred instead forms like ROUTINE..ENDROUTINE or DO..ENDDO etc.
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 set it apart from some other languages was how loops were constructed.
One feature that sets it apart from some other languages is the construction of loops:
 
You had the following types of loops:


DO .... loop statements... ENDDO
DO .... loop statements... ENDDO
Line 71: Line 71:
  ENDDO
  ENDDO


Was similar to a C while (test) { ... } loop.
Is similar to a [[wikipedia:C (programming language)|C]] while (test) { ... } loop.


Another example:
Another example:
Line 80: Line 80:
  ENDDO
  ENDDO


Was similar to a C do { .... } while (test). loop.
Is similar to a C do { .... } while (test). loop.


Some times you could see:
Sometimes programmers wrote:


  DO WHILE test1
  DO WHILE test1
Line 91: Line 91:
In C you would have to write something like while (test1) { .... if (! test2) break; } or some such.
In C you would have to write something like while (test1) { .... if (! test2) break; } or some such.


For loops had the following structure:
''For'' loops have the following structure:


FOR var IN low:high DO .... loop statements.... ENDDO
FOR var IN low:high DO .... loop statements.... ENDDO


You could also specify a step by low:high:step. Alternatively you could 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 could specify an array to loop over an array. You could also specify a pointer:next to walk through a list. For example if you had defined:
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
  TYPE node = RECORD
Line 108: Line 108:
to loop over the list.
to loop over the list.


As a for loop was a loop you could also have WHILE statements inside it. This gave you two possible manners of exiting a for loop, either because the list of values are exhausted or because the test failed. Thus, you could write blocks to catch each of those:
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)
  '''routine''' '''void''',node '''pointer''' (node '''pointer''' : list)
Line 117: Line 117:
  '''endroutine'''
  '''endroutine'''


This would return '''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.
This 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 has a primitive exception mechanism - a routine can return an exception, which is a 16-bit integer value. This can then be caught by an ON ROUTINEERROR statement in the calling scope.
 
== Documentation ==
* {{ND-doc|20.012.2 EN}}
* {{ND-doc|20.013 EN}}
* {{ND-doc|20.034.1 EN}}
* {{ND-doc|860117.6 EN}}


==See also==
==See also==
*[[NORD PL]]
*[[NORD PL]]
== Product  number ==
* [[:Category:ND-10309|ND-10309]]
* [[:Category:ND-10310|ND-10310]]
* [[:Category:ND-10491|ND-10491]]
* [[:Category:ND-211038|ND-211038]]


==Sources==
==Sources==
* {{OriginWP-EN|PLANC|3 April 2009}}  
* {{OriginWP-EN|PLANC|3 April 2009}} (with some updates from 2010)
* Sample code and details of the PLANC programming language have been taken directly from {{ND-doc|60.117.03}}
* Sample code and details of the PLANC programming language have been taken directly from {{ND-doc|60.117.03}}
* [http://home.online.no/~fritekst/PLANC-manual.htm Webpage about PLANC]
* [http://www.fritekst.no/Gamle%20hjemmesider/PLANC-manual.htm Webpage about PLANC]
[[Category:Norsk Data software]]
[[Category:Norsk Data software]]
[[Category:Acronym]]
[[Category:Acronym]]
[[Category:Programming Languages]]

Latest revision as of 22:43, 4 February 2021

PLANC (acronym for Programming Language ND Computers, pronounced as "plank") is a high level system programming language.

Compilers were developed by Norsk Data for several architectures, including the Motorola 68000, 88000, x86, and the Norsk Data NORD-10 architecture and ND-500 supermini.

The language was designed to be platform independent. It was mainly used internally at Norsk Data for writing high level systems software such as the upper parts of the operating systems and compilers.

PLANC basic structure

PLANC programs are structured into modules and routines.

A very simple example of a PLANC program is as follows:

MODULE mod
   INTEGER ARRAY : stack (0:100)
   PROGRAM : mprog
      INTEGER : i, j,k, m
      INISTACK stack
      1 =: i
      2 =: j
      i+j =: k =: m
   ENDROUTINE
ENDMODULE

A difference from popular programming languages is that the assignment operator goes from left to right: First you compute the value, then you store it. Compile-time initialization of variables, on the other hand, went from right to left.

The assignment operator returns the stored value, so you could store it multiple times: 5 =: a =: b would store 5 into both the A and B variables. It shares this direction with Plankalkül, early ALGOL drafts, and Mary, another little known programming language developed in Norway, but also the popular C programming language.

A related distinct syntactic feature is that a function can be defined to take as input the computed value of the expression on its left side. Also, a single additional argument does not require surrounding parentheses. The resulting infix notation blurs the syntactical difference between functions and operators. Such expressions seem conceptually as having a computed value flowing from left to the right.

PLANC data types

As with all high level languages PLANC uses variables as can be seen in the previous sample, here are the allowed data types within PLANC:

An enumeration was declared thus:

ENUMERATION (Winter, Spring, Summer, Autumn) : Seasons := Summer

This defines an enumeration of the seasons and sets the default value to Summer.

LABEL is a little different from your normal data type, this is used to pre-define a label within code and is used in conjunction with a GO statement (very much like GOTO in BASIC).

Access modifiers can be applied to make them READ or WRITE only.

For string data several predefined datatypes are used, they are:

  1. . BYTE Contains a single character
  2. . BYTES Contains character strings
  3. . BITS Contains BIT strings

Array pointers were 3-word constructs that included both the base address, the lower bound and the higher bound of the array; this made it possible to do reliable run-time checking of array boundaries, and made the kind of "pointer arithmetic" that makes C such an "interesting" language much less tempting to write.

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
   .....
ENDDO

Is similar to a C while (test) { ... } loop.

Another example:

DO
   ......
WHILE test
ENDDO

Is similar to a C do { .... } while (test). loop.

Sometimes programmers wrote:

DO WHILE test1
.....
WHILE test2
ENDDO

In 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
ENDRECORD

You 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
endroutine

This 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 has a primitive exception mechanism - a routine can return an exception, which is a 16-bit integer value. This can then be caught by an ON ROUTINEERROR statement in the calling scope.

Documentation

See also

Product number

Sources

  • This article was originally a copy of the English Wikipedia article PLANC in 3 April 2009. (with some updates from 2010)
  • Sample code and details of the PLANC programming language have been taken directly from Norsk Data Document ND–60.117.03 PLANC REFERENCE MANUAL
  • Webpage about PLANC