Tuesday, August 9. 2005F16s and ProgrammingComments
Display comments as
(Linear | Threaded)
The correct code is:
#define Cube(a) (a*a*a) Otherwise, operators with a higher precedence than multiplication could really fuck it up. Example (where #define Cube(a) a*a*a) ++Cube(a) = ++a*a*a = (a+1)*a*a = a*a*a + a*a instead of the expected: a*a*a + 1
Your "correct code" is incorrect. Your reasoning is reasonable.
It's been a long time since I used macros
x+3*x+3*x+3 = 7*x + 3 New #define: #define Cube(a) ( (a) * (a) * (a) )
Functionally they seem a bit like lambda expressions from python but the lambdas lack the pre-processing part. I wonder is there any closer comparison in python.
Btw, just to make that link even more tenuous; to the best of my knowledge, the several million odd lines of code in the F16's avionics systems are all written in Ada.
|
About:Switch to Dark on Light!
This website is the online diary of me, Des Traynor, a User Experience Researcher in Dublin, Ireland. I work with Contrast. I usually write on 5 topics: I update about 3-4 times per month. Be sure to subscribe so you don't miss this good stuff. If this is your first time here, check out the archives.My official homepage provides more information about who I am, and what I research. You can contact me at destraynor [at] gmail [dot] com Quicksearch |
Hmm, must get back to posting here. The Minds "blog scene", as it were, has been taking off nicely since myself, Des, etc started into it a couple months ago. Planet Minds now features 14 blogs, a decent collection. The old hands; Aidan, Baruch, Dave Barr
Tracked: Aug 17, 16:20