[M3devel] comparisons vs. subranges

Jay K jay.krell at cornell.edu
Sat Mar 13 11:19:21 CET 2010


<*UNUSED*>PROCEDURE CardinalGE0(a:CARDINAL):BOOLEAN=BEGIN RETURN a>=0; END CardinalGE0;
<*UNUSED*>PROCEDURE CardinalEQN1(a:CARDINAL):BOOLEAN=BEGIN RETURN a=-1; END CardinalEQN1;


 

Seems to me, the front end should notice these.

The first should always be TRUE.

   And possibly, possibly warn.

The second should always be FALSE.

   And possibly, possibly warn.

 

"Generic" programming often hits this sort of thing though, a good reason not to warn.

Programmer might also be working with existing code and have changed INTEGER to CARDINAL.

  Or be defending against future maintainers changing CARDINAL to INTEGER.

 

 

The backend isn't give enough information, because CARDINAL = INTEGER as far

as it is told. Due to the half range of CARDINAL and LONGCARD, that isn't wrong.

The only way to get unsigned types is to use ADDRESS from what I see.

 

 

 - Jay

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100313/38187c50/attachment-0001.html>


More information about the M3devel mailing list