IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Ooh, he left out the ^

and a line

void swap_int(int& x, int& y)
{
x ^= y;
y ^= x;
x ^= y;
}



"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
New That's just evil to the core. :-)
New It's C++, what do you expect?



"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
New I would only use that if it were properly commented.

Is it enough to love
Is it enough to breathe
Somebody rip my heart out
And leave me here to bleed
 
Is it enough to die
Somebody save my life
I'd rather be Anything but Ordinary
Please

-- "Anything but Ordinary" by Avril Lavigne.

New I'd probably never use it at all
Its a cool parlor trick I think. Thats about it.



"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
New Its a cool parlor trick...
...that has an annoying tendancy to show up on the [insert correct TLA here; the name of the test that you have to take to get into a Master's program] test.

(This gettin old just isn't what it's cracked up to be...)
jb4
"We continue to live in a world where all our know-how is locked into binary files in an unknown format. If our documents are our corporate memory, Microsoft still has us all condemned to Alzheimer's."
Simon Phipps, SUN Microsystems
New Not even really a C++ issue as such, is it?
You can do that evil thing he did in ANSI C with pointers.

Have you seen this?

\nregister n = (count + 7) / 8;      /* count > 0 assumed */\n\n   switch (count % 8)\n   {\n   case 0:        do {  *to = *from++;\n   case 7:              *to = *from++;\n   case 6:              *to = *from++;\n   case 5:              *to = *from++;\n   case 4:              *to = *from++;\n   case 3:              *to = *from++;\n   case 2:              *to = *from++;\n   case 1:              *to = *from++;\n                      } while (--n > 0);\n   }\n


Now THAT is evil!
-drl
New Its a Duff Device
and as an optimization for moving chunks of data rapidly its pretty good.




"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
New Yep - it's assembler in C
-drl
New Most ASM Languages have a SWAP instruction.
New Yes, not my point
My point was that C is syntactically capable of these kinds of weird things you might use at a very low level.
-drl
New And my point...
... (if there's really a point to be made) is that this is even lower level than assembly language (unless you count the One Instruction Machine). More like programming ASIC's. :-)
New SWAP?
SWAP? Did you mean MOVB/MOVW?
--
-- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New That's ANSI C?!?
ANSI C compilers I've run across recently wouldn't allow you to put a
case
label inside of a block (i.e. inside of an open curly brace).

I know ANSI C++ won't let you...
jb4
"We continue to live in a world where all our know-how is locked into binary files in an unknown format. If our documents are our corporate memory, Microsoft still has us all condemned to Alzheimer's."
Simon Phipps, SUN Microsystems
Expand Edited by jb4 May 14, 2003, 01:46:33 PM EDT
New That's ANSI C?!? ... YES
I just tried it undef GNU C++, GNU C and Solaris C++. Duff's device works fine under all of them.

(NOTE: I had to change "register n" to "register int n" for it to work in C++).
--
-- Jim Weirich jweirich@one.net [link|http://w3.one.net/~jweirich|http://w3.one.net/~jweirich]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
Expand Edited by JimWeirich May 14, 2003, 01:58:08 PM EDT
New Re: That's ANSI C?!?
No, it's antsy C!

Took me a while to figure out what the hell it was for the first time I saw it.
-drl
     Cringely on Refactoring - (tjsinclair) - (41)
         He's still skirting the real issues to make his "point". - (admin) - (39)
             Good point - (tjsinclair) - (38)
                 Do I use unit tests? - (admin) - (34)
                     Apparently my question sounded dumber than it actually was - (tjsinclair) - (33)
                         Lessons to be gleaned: - (admin) - (16)
                             Great stuff! - (tjsinclair) - (2)
                                 Re: Great stuff! - (admin)
                                 C++ unit testing - sounds painful - (tuberculosis)
                             More: - (admin) - (1)
                                 Code coverage - (Simon_Jester)
                             How does JUnit (and the like) deal with web pages? - (drewk) - (5)
                                 Not really specific to PHP. - (admin) - (3)
                                     Also from that page - (drewk) - (2)
                                         HttpUnit is more useful for integration testing. - (admin)
                                         We use PHPUnit where I work. - (static)
                                 I'm experimenting with testing dynamic content ... - (JimWeirich)
                             Can I quote this thread? - (tjsinclair) - (4)
                                 Even better: - (admin) - (2)
                                     No, you can't use my comments - (drewk)
                                     Thanks! - (tjsinclair)
                                 A TDD Example - (JimWeirich)
                         Ooh, he left out the ^ - (tuberculosis) - (15)
                             That's just evil to the core. :-) -NT - (ChrisR) - (1)
                                 It's C++, what do you expect? -NT - (tuberculosis)
                             I would only use that if it were properly commented. -NT - (static) - (12)
                                 I'd probably never use it at all - (tuberculosis) - (11)
                                     Its a cool parlor trick... - (jb4) - (10)
                                         Not even really a C++ issue as such, is it? - (deSitter) - (9)
                                             Its a Duff Device - (tuberculosis) - (5)
                                                 Yep - it's assembler in C -NT - (deSitter) - (4)
                                                     Most ASM Languages have a SWAP instruction. -NT - (ChrisR) - (3)
                                                         Yes, not my point - (deSitter) - (1)
                                                             And my point... - (ChrisR)
                                                         SWAP? - (JimWeirich)
                                             That's ANSI C?!? - (jb4) - (2)
                                                 That's ANSI C?!? ... YES - (JimWeirich)
                                                 Re: That's ANSI C?!? - (deSitter)
                 Re: Good point - (JimWeirich) - (2)
                     Another good point - (admin) - (1)
                         Me too. - (static)
         FWIW, Squeak is undergoing a huge refactoring effort - (tuberculosis)

This one is just screaming out for some deep massaging in Perl.
86 ms