PASCAL as a systems programming langugage

Kevin Szabo ksbszabo at wateng.UUCP
Mon Jan 14 13:45:36 AEST 1985


In article <571 at vu44.UUCP> jack at vu44.UUCP (Jack Jansen) writes:
	( editted quite a bit by me, Kevin Szabo )
>  Ok, let me throw in my $1E-1 worth of opinion.
>  Well, what I like most about pascal is that it *works*.
>  By this, I mean that if a C program takes an hour to write
>  and a pascal program 2 hours, the pascal program is debugged
>  in 20 minutes, and the C program in 2 days.
>  I have seen this also with friends of mine, so I don't think it
>  can be influenced by a difference in experience or other personal
>  factors, I think that pascal, by *forcing* you to define your
>  data, parameters, etc. correctly points you to a lot of logic errors
>  (and typing errors), where C will have you addicted to coffee and
>  tobacco by the time you locate the missing &.

I agree whole heartedly that forcing the programmer to define data,
parameters etc. will improve correctness in code. Actually in a recent
note to the mod.standard-c newgroup I suggested adding stronger typing
to C, as well as some other goodies. Of course the moderator (quite
rightly and wisely) pointed out that this fell into the class of
additions to C, and thus did not belong in the standard. He also
pointed out that check programs, such as lint, are not part of the
standard and hence could enforce strict type checking for those that so
wished. This holds great promise for me since I like C but I also like
the compiler to tell me when I have been stupid and passed the wrong
type of argument to a function. I had previously hoped that typedef's
would allow me to create my own types that would be checked by lint,
but presently they are only aliases which are immediately promoted to
their basic type when encountered.  Hence they do not pick up errors
such as:

	typedef foo	int;	/* These typedefs might be wrong */
	typedef bar	int;
	
	main()
	{
		foo a;	bar b;
		get_a_and_b( &b, &a );
		....
	}
	
	get_a_and_b( a, b )
	foo	*a;
	bar	*b;
	{ };

Sooo... if anybody out there in net-land is hacking away at LINT you could
possibly try adding a `super typechecking' option (that has to be explicitly
turned off!). I suggest that it strictly enforces type checking when calling
functions and, in order not to be innudated with billions of warnings,
it will promote the derived type (foo) to its basic type (int) whenever
mixed arithmetic is attempted. (mixed arithmetic in the sense of 
typea = typeb + typec; the Derived types)

It doesn't effect CC but allows the disciplined programmer the type
checking that s/he requires. What say ye?

			Kevin
-- 
Kevin Szabo  watmath!wateng!ksbszabo (U of Waterloo VLSI Group, Waterloo Ont.)



More information about the Comp.lang.c mailing list