Newsgroups: comp.lang.misc
Path: utzoo!utgpu!jarvis.csri.toronto.edu!turing.toronto.edu!holt
From: holt@turing.toronto.edu (Ric Holt)
Subject: Re: Turing programming language.
Message-ID: <89Jan18.135910est.4327@turing.toronto.edu>
Keywords: programming language
Organization: /usr/local/lib/organization
References: <11@euteal.UUCP>
Date: Wed, 18 Jan 89 13:59:06 EST

TURING VERSUS MODULA

These two languages are designed with many similar goals and are
very much alike in many ways.  Turing proper does not contain
separate compilation or systems programming features, which are
features of Modula and of Turing Plus.  A couple of areas where
Turing differs from Modula will be listed.

1) Turing is good for introductory programming.  For example, here
is a program that a high school student might write:

	var s : string := "*"
	loop
	    put length(s) : 3, " ", s
	    s := s + "*"
	end loop

The output of this program is:
	  1 *
	  2 **
	  3 ***
	  ...etc...

Likely the same student would get frustrated trying to program this in
Modula.

2) Turing is good for formal verification.  It has a weakest precondition
formal semantics.  Here is a Turing procedure that converts an integer,
such as 15, to a corresponding dollar string, in this case to $0.15.  This
function illustrates Turing's assertions (pre, post, assert), which are used
in verification:

	function dollarInt ( i : int ) answer : string
	    pre i >= 0     % Give restrictions on input
	    post           % Give requirements for correct result
	         answer(1) = "$" and
		 answer (* - 2) = "." and  % Decimal point two from end
		 i = strint( answer (2 .. *-3) + answer (*-1..*))
			% answer must represent same value as i
	    var t := intstr ( i )    % Convert i to a string
	    if length(t) = 1 then
		t := "00" + t
	    elsif length(t) = 2 then
		t := "0" + t
	    end if
	    assert length (t) >= 3   % Must be long enough to insert point
	    result "$" + t (1 .. *-2) + "." + t(*-1 .. *)
		% Result of function is $ then digits of t up to insertion
		% then decimal point then final two digits
	end dollarInt

Of course, you don't need to use assertions if you don't want to, and you
can ask the compiler to ignore them (by default, it generates code to
check them).

Finally, Turing Plus has various features that Modula doesn't have, such as:
	Exception handling (or does Modula have this?)
	True concurrency (processes run physically in parallel on
		shared memory multiprocessors)
	Nice numerical features (Turing or Numerical Turing are convenient
		for numerical analysis work).

