<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>CONST is faster than VAR since the compiler can optimize them.  Why would you want VAR?</div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><br></div></span></span></span></span></span></span></span></span></div></span></div><div><div>On 11 Jan 2009, at 19:58, Jay wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">I still find pushing the system dependencies and cloned headers out of the system very tempting.<br>  To reduce what it takes to port to other systems, to raise the confidence of the correctness of any port, to keep ports correct in the face of possible underlying change.<br> <br>I think I'll change the case statements to if/else ladders and the consts to vars, that are actually statically initialized in C. This treatment is reasonable for other constants that remain in the cloned headers, system dependent or otherwise.<br> <br> - Jay<br><br><hr id="stopSpelling"><br>From:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: making Uerror "portable"?<br>Date: Thu, 8 Jan 2009 06:36:44 +0000<br><br>I've been thinking about "fixing" Uerror<br>to remove the system-dependentness of it.<br> <br><br>I have about given up.<br> <br><br>There are multiple easy options, but they<br>all have downsides that make me think it<br>might not be worth it.<br> <br><br>today it looks like:<br> <br> <br>INTERFACE Uerror;<br>CONST<br>  ENOFILE = 1;<br>  ENOMEM = 2;<br>END Uerror;<br> <br> <br>The values are intended the correct native values.<br>There are a fair number of users.<br>Fewer than 10 probably.<br>They include switch/case statements, which require<br>constants.<br> <br><br>The following are some of the possible changes,<br>that make porting to basically any future system<br>be a no-op in this area, except for the occasional missing or possibly<br>equal errnos (if there is a switch in the C code; I ran into this case).<br> <br><br> - Change to VAR and initialize them in portable C code.<br> disadvantages:<br>   more startup code<span class="Apple-converted-space"> </span><br>      possibly startup code runs too late<span class="Apple-converted-space"> </span><br>   more writable/written data (readonly data is best)<span class="Apple-converted-space"> </span><br>   slower to access<span class="Apple-converted-space"> </span><br>   not constant, not switchable, not source quite compatible<br>     You have to change the switch statements to "if ladders" (if/elseif/elseif/elseif).<br>     Compatible with most source, and incompatible source easily fixed.<br>   possible issues around "dynamic linking data" (not explained here, ask?)<span class="Apple-converted-space"> </span><br>   However not really a problem. More of a problem only on NT, and easily worked<br>    around just like is done for hand.obj.<br> <br><br> - change to VAR and const static initialize them in portable C "data"<br>   no additional startup code -- guaranteed initialized early enough<span class="Apple-converted-space"> </span><br>   no writable/written data<br>   slower to access<span class="Apple-converted-space"> </span><br>   not constant, not switchable, not source compatible (same as previous)<span class="Apple-converted-space"> </span><br>   same non-issue around dynamic linking of data<span class="Apple-converted-space"> </span><br> <br><br> - change to functions GetENOFILE(), GetENOMEM(), etc.<br>   slower to access<br>   definitely no problem dynamic linking<span class="Apple-converted-space"> </span><br>   easier to write the C code/data, no matter, the above<br>     are easy enough<span class="Apple-converted-space"> </span><br>   not constant, not switchable, not source compatible (similar to previous)<span class="Apple-converted-space"> </span><br> <br><br> - "translation"; introduce our own arbitrary values for<br>   any errno the system uses; change Cerrno.GetErrno to have<br>   a switch and translate from the native values to ours.<br> <br><br>   This is fully source compatible, dynamic link compatible,<br>    in-between perf wise (slower to GetErrnor, but then constant<br>    and just as comparable/switchable), no initialization cost.<br> <br><br>   Question then though what does any raised exception look like?<br>   Do the values get translated back? Or translated to strings?<br>   SetErrno translates back?  <span class="Apple-converted-space"> </span><br>  <span class="Apple-converted-space"> </span><br> <span class="Apple-converted-space"> </span><br>   Translation is at first simple and is unique among portable solutions<br>    in its source compatibility, but I am leary of it. I would<br>    rather a solution that traffics in unmodified native errnos values, but<br>    I don't that is viable with both constness and portability.<br>   <br>  <br>   To a large extent, translation is ok. If you look at SocketPosix.i3, it<br>    uses the errno very briefly to determine the next step to take. I don't think<br>    it ever returns or RAISEs it (or an exception containing it).<br><br>    But other parts of the system Fmt.Int(errno) and raise that, thus<br>    these become values that move through more of the system and therefore<br>    disagreement with the underlying system might show through.<br> <br><br>  There is also question of how to chose "Max". Set it large, like 200?<br>  Set it "correctly"? Probably a better option is to make the cache<br>  that is currently Max-sized be instead small and fixed-size (e.g. 64),<br>  and "search" it quickly instead of "indexing" it very quickly, and always<br>  kick out the least recently used. I also have to check what the<br>  contents actually are, perhaps they are constant-initializable.<br>  <br> <br> Thoughts?<span class="Apple-converted-space"> </span><br> <br><br> I was somewhat keen to do something here, but have pretty much given up and<br>   will just generate Uerror.i3 for Solaris, NetBSD, FreeBSD, AIX, Irix, HP-UX, etc..<br>   I might still be able to remove the Usignal and Ustat system-dependentness<br>   in m3core/src/unix, but Uerror will probably stand asis (in linux-common,<br>   openbsd-common, cygwin).<br> <br> <br>In particular, I was putting off any more ports till I got the amount of work needed<br>to port reduced to my satisfaction. I think I'm nearly there.<br> <br><br> - Jay<br><br><br></div></span></blockquote></div><br></body></html>