- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Turbo Pascal on the Mac did rule for quite a while.
Most APIs use Pascal calling convention for speed. The only requirement is a fixed argument list. Pascal calling convention requires that the callee cleans the stack. This allows a return with stack adjustment as a single operation. Every instruction cycle was really important when we used to run Windows 2.1 on 12Mhz 286 boxes. (It was amazingly fast, even on those new fangled 640x480 VGA monitors)
C calling convention requires that the caller cleans the stack (This is what allows variable argument lists, ...). This means the the callee just returns, the caller then performs a second operation to reclaim the stack space used by the function arguments.
All of the old Windows APIs (and probably the new OS level ones) used Pascal calling convention even though all of the development tools were in C.
Captcha: captcha? I hope this works...
Admin
Well, in 1977 it became the Fortran version.
captcha: billgates
Admin
"I suspect that the "FORTRAN" is part of the anonymization; if this was really for the Mac, I'm betting the language involved was actually Pascal, since Apple was pushing Pascal when the Mac first came out, and only later switched to C."
I actually wrote FORTRAN software on the Mac back in the day. Believe it or not since the Mac has always leaned toward the GUI Interfaces, the FORTRAN compiler that was available had a direct link into the OS routines and a complete API that allowed GUI interfaces to be written completely in FORTRAN.
It was actually really nice..and it was blazing fast for its time. I once benchmarked one program I wrote on a 16 MHz Mac IIci (Motorola 68020), a 32 MHz IBM PC (Intel 386 Winders 3.1, Sun Sparc One, and VAX Mini Micro. The Mac version was over 2 Minutes faster in run time over the PC, 3 minutes faster than the Sun and ~30 sec faster than the VAX. It was .. in a word... a kick-ass FORTRAN implementation. And since the Apple Math engine at the time was REALLY good (90 bits of Math accuracy, 1st NAN error codes, cos(180) = 0 exactly....not out to some arbitrary decimal length. I had already dropped my Cray account in favor of the Mac a couple years earlier.
Oh and FORTRAN is still used in science pretty heavily since even though a lot of the really complex Math libraries are still more powerful for that language than in any other. FORTRAN has been able to do Graphics since the early 70s....Anyone remember DISSPLA?? Completly written if FORTRAN.
That's the package I started in computers with....I was making movies in the early 80s at $700 per CPU hour on a Cray II.
Wheee!!
Admin
Fortran arrays, since f77, don't start at 1 - they can assume any range e.g. my_array(100:100). Converting a lot of those to start at 0 would require careful bookkeeping.
Admin
The compiler, as I recall, was pretty capable, yes. But who cared? The Cray glommed it up and spat it out in a fraction of a second HOWEVER badly you wrote it ;-)
Admin
Re the above paragraph--see the original tailor story--your solution is 'walk funny.'
Admin
My father probably heard it in the 1920's, his heyday of yiddish comedy. I suspect the original story was something like "Ramses asked Thutmose to make him a new loincloth..."
Admin
*s/float/double/g and if he has more than $1.7E+306, screw him.
Admin
That's a myth. Nothing in ISO 9899 "requires that the caller [clean] the stack". While there are various requirements for how functions are called and how function calls behave, provided the program does not invoke undefined behavior, that isn't one of them.
It's perfectly permissible to implement variadic function calls with a hidden extra parameter that tells the called function how to clean up, for example.
There are platforms which use the same ABI for C and Pascal, with none of this "calling convention" nonsense (eg AIX on PPC). There are C implementations on systems that provides direct support for variadic calls, and the C implementation doesn't worry about "cleaning up the stack" at all (eg EPM C on AS/400).
-- Michael Wojcik
Admin
ISO 9899 was not adopted until 1999, we were talking about technologies that were available in mid to late 1980's.
I agree, that Pascal vs. C calling idiom is more of a Windows (antiquated) API convention. I think they call it stdcall or something now.
Your own rebuttal provides evidence that the caller must at least provide extra information (overhead) to the callee for cleanup purposes. Fixed parameter lists will always allow more options for platform specific optimizations.
Admin
Ahh, this one brought back the memory of when I was asked to knock up a little database program to print out name and address labels of our customers - doing it with the word processor mail-merge was a pain, apparently. I hacked something together in Clipper (anyone remember Clipper?) that did the bare minimum.
A week or so later, the company sales rep dropped a glossy leaflet on my desk. "What about this then?" he asked, smugly. The leaflet said "Marketing Manager!" in shouty bold letters and continued: "Organise and store your customer information, search and sort on multiple fields, print lists, letters, labels...", etc.
I groaned - "Wow, that looks great - but I wish you'd told me we were selling this, because I needn't have wasted a couple of days hacking that crappy label printing thing!"
"No, no," he said, "You don't understand, this is the label printing program you wrote..."
I groaned even louder.
Admin
He did, but the Skipper was head of rewrite and Gilligan was the lead developer.
Admin
Admin
Typical Apple Computer murder.