Assignment in test: OK?

John Kewley ICL jk at cs.man.ac.uk
Fri Sep 14 03:28:00 AEST 1990


In article <1990Sep12.194753.9808 at laguna.ccsf.caltech.edu>, bruce at seismo.gps.caltech.edu (Bruce Worden) writes:
> are legal, I don't see how `:=' is any better than just `='.  People who
> are used to thinking of `:=' as `equal' will type it as freely as we 
> type `='.
>
> Only something like Fortran's .EQ. is different enough to 
> draw attention to the two different meanings of `is equal to'.
>
> I am not objecting to constructs like:
> 	if((fd=open(path,flags,mode)) != NULL)

My first real language I learnt was a language called S-Algol developed at
St. Andrews University. It had several neat features that were helpful to
novice programmers, the relevent one in this case being:

	let x = 3	! x is a constant of value 3
	let y := 4	! y is a variable of value 4
	y := 5		! assign 5 to variable y
	if y = 5
	then
		write "y = 5'n"
	else
		write "y ~= 5'n"
	for i = 1 to y
	do
		write "i = ", i, "'n"

Types were inferred from expressions provided.

Note that equality and initialisation of constants both use "=" and
that assignment and initialisation of variables use ":="

What to some might be counter-intuitive is that instead of a looping
variable, S-Algol has a looping constant which cannot be altered during the
loop (since it is constant).

S-Algol had many other "nice" features and proved excellent for
programming-in-the-small.
--
        J.K.
 
John M. Kewley, ICL, Wenlock Way, West Gorton, Manchester. M12 5DR
Tel:   (+44) 61 223 1301 X2138  Email: jk at r6.cs.man.ac.uk / jk at nw.stl.stc.co.uk



More information about the Comp.lang.c mailing list