<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Mika, you mean [-1..LAST(INTEGER)] right?<BR>
<BR>
- Jay<BR><BR> <BR>> To: jay.krell@cornell.edu<BR>> Date: Sun, 18 Apr 2010 12:41:59 -0700<BR>> From: mika@async.async.caltech.edu<BR>> CC: m3devel@elegosoft.com<BR>> Subject: Re: [M3devel] Posix < 0 vs. # 0 vs. = -1?<BR>> <BR>> Jay K writes:<BR>> >--_201b8a99-e8e8-4887-bb32-c65e8edd0b1a_<BR>> >Content-Type: text/plain; charset="iso-8859-1"<BR>> >Content-Transfer-Encoding: quoted-printable<BR>> ><BR>> ><BR>> >Posix often says:<BR>> ><BR>> > function foo() returns 0 for success=2C -1 for error<BR>> ><BR>> >=20<BR>> ><BR>> > m3core/libm3/etc=2C often say if foo() < 0 or if foo() # 0 "instead".<BR>> > Generally ok to tighten these up to "=3D -1"=2C perhaps upon checking manp=<BR>> >ages=2C<BR>> > or a known rat's nest of inconsistencies?<BR>> ><BR>> <BR>> Maybe this is just my personal style, but I would code it thus:<BR>> <BR>> <*EXTERNAL*><BR>> PROCEDURE F() : INTEGER; (* matches C declaration *)<BR>> <BR>> ...<BR>> <BR>> VAR result : [0..1] := F(); (* matches man page specification *)<BR>> BEGIN<BR>> CASE result OF <BR>> 0 => ...<BR>> | <BR>> -1 => ...<BR>> END<BR>> END<BR>> <BR>> No way for any sneaky value problems to get through. The use of<BR>> CASE also guards against typos.<BR>> <BR>> Mika<BR> </body>
</html>