Why nested comments not allowed?

D.S. Cartwright cmp8118 at sys.uea.ac.uk
Wed Feb 21 22:21:04 AEST 1990


Forgive me if I'm wrong (for this is just a guess) but perhaps the availability
of nested comments is simply a decision by the original language designer based
on the eventual implementation of the thing.

	For example, someone heavily into recursion would probably include
nested comments, as they can then be dealt with recursively, something like :

	Function CommentAnalyse
	   Do
	      Get token
	      If token = 'Open Comment'
	          Call CommentAnalyse
	   Until token = 'Close Comment'
        End Function

	(in a completely no-existent language that I just made up).

  On the other hand, they might not consider recursion. This would mean that
an iterative method would have to be used to find the end of a comment. If,
then, nested comments were required, a counter would have to be stored with
details of how many 'Open Comment' tokens we had had so far. With no nested
comments, it's much easier to do (no counter is needed):

	Function CommentAnalyse
	   Do
	      Get token
	   Until token = 'Close Comment'
        End Function

	(in the same non-existent language).

   Perhaps I am talking utter rubbish, and language designers have better
things to think about than how their design is going to be implemented. It
just seems rather a coincidence that the two basic methods of processing
(iteration and recursion) fall into line with the two types of comment (nested
and non-nested).

	Anyone else got any thoughts ?? Can anyone categorically state that
I'm wrong (my Programming Systems lecturer will probably rip my argument to
bits, but that's nothing new) ?? If so, I'd appreciate your views.

	Dave C.
-- 
 Dave Cartwright,               | cmp8118 at uk.ac.uea.sys    <- Here
 School of Information Systems, | cmp8118 at uk.ac.uea.cpc780 <- Somewhere else
 University of East Anglia,     |  Just 'cos I'm thick ...
 Norwich, ENGLAND. NR4 7TJ.     |         ... don't take it out on ME !!



More information about the Comp.lang.c mailing list