<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>I insist that it depends.<BR>
Putting every platform-specific piece of code in its own file/directory can lead to mass duplication of nearly identical code.<BR>
Sometimes an #if here or there goes very far in /improving/ code maintainability.<BR>
A lot of #if here there and everywhere of course can have the opposite effect.<BR>
And I realize if you were to drop support for a target, it is easier to find/delete files/directories than #ifs, but I don't think that's a good enough reason to sway the decision.<BR>
It goes both ways.<BR>
<BR>
Yes, you could endeavor factor things down so that everything common is in common, and everything not-common is in platform-specific. But this is inadequate I think. The tail is wagging the dog unnecessarily I think. If my code very nearly all goes together, don't make me separate it. Also sometimes a different factoring is "encouraged" for other reasons, to match someone else's factoring. Look at the C*.i3 files. They actually can be almost all be nearly the same, yet they are hardly shared at all. I realize you could also do a sort of "forwarding", though I'm not sure that Modula-3 offers all the right capabilities for this. Type forwarding, sure. But how about procedure forwarding? Like nt386\cstdio.i3 fopen = common\ccommonstdio.i3 fopen? And having to duplicate a line per type/procedure is lame anyway, you KIND OF want "module inheritance". However, if you allow preprocessing based on target, perhaps the need for that goes away.<BR>
<BR>
While extern C varargs functions are generally useless in Modula-3, and therefore extern __cdecl is fairly rare, it DOES occur when you write little helpers in C, such as for errno.<BR>
<BR>
A good /heuristic/ might be to change the default in any directory that has no c_source.<BR>
But it is only heuristic.<BR>
<BR>
Whatever is done here, some allowance should probably be made for multiple calling conventions in the same file.<BR>
Switching the default to the overwhelming majority and then annotating the minority is reasonable.<BR>
<BR>
I still believe that silently ignoring calling conventions on all but NT386 is VERY reasonable, and that no other platform from here on out will ever have calling conventions. Esp. not with the same names. When OS/FOO has the FOOAPI calling convention, you can just ignore that one on all but target OS/FOO. Just as all but NT386 ignore WINAPI. Yes this COULD possibly get ugly something like:<BR>
<*EXTERN FOOAPI WINAPI*> fopen();<BR>
FOOAPI for OS/FOO, WINAPI ignored.<BR>
WINAPI for NT386, FOOAPI ignored.<BR>
The One True Calling Convention for all others, calling convention ignored.<BR>
<BR>
I really believe this is highly highly unlikely to occur, and it is not a terrible outcome, and this bridge could be crossed in the far off future.<BR>
The functions that are usually in need of calling conventions are usually only present on one system.<BR>
Perhaps ODBC is an extremely rare anomaly and the whole issue is nearly nonexistant.<BR>
That could be also.<BR>
A change just for ODBC is probably not the best, though it is a very small safe harmless change (I always say that :) )<BR>
<BR>
<BR>
- Jay<BR><BR>
<HR id=stopSpelling>
<BR>
> CC: jayk123@hotmail.com; m3devel@elegosoft.com<BR>> From: hosking@cs.purdue.edu<BR>> Subject: Re: [M3devel] "target specific pragmas"?<BR>> Date: Mon, 11 Feb 2008 21:08:46 -0500<BR>> To: darko@darko.org<BR>> <BR>> Indeed!<BR>> <BR>> On Feb 11, 2008, at 8:37 PM, Darko wrote:<BR>> <BR>> > I think it's not a good idea. I think all platform specific code <BR>> > should be in a separate file. I'd also like to see an option to <BR>> > move calling conventions to the makefile rather than in pramas to <BR>> > avoid having to duplicate interface files just to have a different <BR>> > calling convention for a different platform.<BR>> ><BR>> > - Darko<BR>> ><BR>> ><BR>> > On 12/02/2008, at 12:21 PM, Jay wrote:<BR>> ><BR>> >> So I have NOT thought this through.<BR>> >><BR>> >> I wonder if "preprocessing" dependent only on "target" is a good <BR>> >> idea.<BR>> >><BR>> >> Something like either the ability to prefix pragmas with a target, <BR>> >> or an "iftarget" and "ifnottarget" pragma.<BR>> >><BR>> >> Something like so:<BR>> >><BR>> >> <* IF_TARGET NT386 *><BR>> >> <* END_IF_TARGET*><BR>> >><BR>> >><BR>> >> <* IF_TARGET NT386 *><BR>> >> <* END_IF_TARGET*><BR>> >> It's a small can of worms.<BR>> >> Where can they be placed? Only at "global" scope? (ie: toplevel in <BR>> >> an interface/module).<BR>> >><BR>> >> What about IF_OSTYPE?<BR>> >> What about expressions?<BR>> >> IF_TARGET NT386 OR NTAMD64<BR>> >><BR>> >> IF_TARGET STARTS(NT)<BR>> >><BR>> >> etc.<BR>> >><BR>> >> I don't really have enough interest here to work through this, <BR>> >> just sending out the bait...<BR>> >><BR>> >> Obviously this was triggered by my happening into the odbc <BR>> >> directory and bringing up ignoring WINAPI on non-NT386 or <BR>> >> prefixing calling conventions with a target.<BR>> >><BR>> >> This reminds me of an important point here however -- nobody else <BR>> >> is going to make the mistake of ever having multiple calling <BR>> >> conventions. Therefore the generality of prefixing WINAPI with <BR>> >> NT386: is useless.<BR>> >> Unless Mac68K support is added.<BR>> >><BR>> >> And here is some rationale even. The PC and Mac evolved from <BR>> >> "small" systems, where assembly programming was common, more <BR>> >> people knew more lower level details and playing games with <BR>> >> calling conventions was something anyone could do. Most other <BR>> >> current systems are rooted in C programming. Working in C, calling <BR>> >> conventions are generally in a hidden layer below what anyone <BR>> >> thinks about. Therefore, the smaller number of capable people <BR>> >> working at that level have the good sense to only have one calling <BR>> >> convention. No more systems will evolve from "small", at least not <BR>> >> without having observed this history. Therefore, there will no <BR>> >> longer be multiple calling conventions.<BR>> >><BR>> >> That is my theory at least.<BR>> >><BR>> >> Oh, Windows does also have __thiscall and __clrcall. __thiscall is <BR>> >> only x86<BR>> <BR><BR><br /><hr />Climb to the top of the charts! Play the word scramble challenge with star power. <a href='http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan' target='_new'>Play now!</a></body>
</html>