[M3devel] comparisons vs. subranges

Jay K jay.krell at cornell.edu
Sat Mar 13 11:49:37 CET 2010


I might be able to do this. Give me a day or so..

 

 - Jay

 


From: jay.krell at cornell.edu
To: hosking at cs.purdue.edu; m3devel at elegosoft.com
Date: Sat, 13 Mar 2010 10:19:21 +0000
Subject: [M3devel] comparisons vs. subranges



<*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/b08950f2/attachment-0002.html>


More information about the M3devel mailing list