[M3devel] Posix < 0 vs. # 0 vs. = -1?

Jay K jay.krell at cornell.edu
Mon Apr 19 06:37:12 CEST 2010


Mika, you mean [-1..LAST(INTEGER)] right?

 

 - Jay

 
> To: jay.krell at cornell.edu
> Date: Sun, 18 Apr 2010 12:41:59 -0700
> From: mika at async.async.caltech.edu
> CC: m3devel at elegosoft.com
> Subject: Re: [M3devel] Posix < 0 vs. # 0 vs. = -1?
> 
> Jay K writes:
> >--_201b8a99-e8e8-4887-bb32-c65e8edd0b1a_
> >Content-Type: text/plain; charset="iso-8859-1"
> >Content-Transfer-Encoding: quoted-printable
> >
> >
> >Posix often says:
> >
> > function foo() returns 0 for success=2C -1 for error
> >
> >=20
> >
> > m3core/libm3/etc=2C often say if foo() < 0 or if foo() # 0 "instead".
> > Generally ok to tighten these up to "=3D -1"=2C perhaps upon checking manp=
> >ages=2C
> > or a known rat's nest of inconsistencies?
> >
> 
> Maybe this is just my personal style, but I would code it thus:
> 
> <*EXTERNAL*>
> PROCEDURE F() : INTEGER; (* matches C declaration *)
> 
> ...
> 
> VAR result : [0..1] := F(); (* matches man page specification *)
> BEGIN
> CASE result OF 
> 0 => ...
> | 
> -1 => ...
> END
> END
> 
> No way for any sneaky value problems to get through. The use of
> CASE also guards against typos.
> 
> Mika
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100419/29e463ce/attachment-0002.html>


More information about the M3devel mailing list