|
0x1C to 0x1F are clear the best bytes to delimit data with.
|
# ? Jun 14, 2008 13:21 |
|
|
# ? May 16, 2024 18:54 |
|
I should have clarified, the file has to be a valid "text" file in single encoding. While you could delimit the data like that, it would be mixed encoding and would piss off text editors. In other words, the 0xFE bytes are tripping complaints from programs reading them about that byte not being valid utf8, and this is where the wtf complaints come from... "I thought anything could be unicode". npe fucked around with this message at 13:59 on Jun 14, 2008 |
# ? Jun 14, 2008 13:36 |
|
0x1C to 0x1F are valid ASCII, and valid utf-8 encodings. Whether or not your text editor will like them I don't know.
|
# ? Jun 14, 2008 14:37 |
|
From a test I recently corrected. __m128 y = _mm_mul_ps(x, _mm_set1_ps(1.0f)); This is an SSE y = x*1; __m128 rcp = _mm_rcp_ps(_mm_set1_ps(1.0f)); rcp = 1/1; Wait, there's worse __m128 rcp = rcp_nr(_mm_set1_ps(1.0f)); Hrmm. SSE reciprocal is not very accurate. I know, let's use a newtown rhapson iteration to increase the accuracy of our 1/1 calculation!
|
# ? Jun 14, 2008 16:35 |
|
I wrote a 3000-line function once. It included a "goto". No, I'm not going to paste it in here. Took about five minutes to compile. I think I determined that GCC's optimizer was O(n^2) in the number of lines. I cleaned it up once it was finished and split it into three or four functions (yes, still behemonths of functions, but they did big complex things and splitting it up further would have just made it less readable.)
|
# ? Jun 14, 2008 22:21 |
|
ZorbaTHut posted:I wrote a 3000-line function once. It included a "goto". 3000 lines is , but there's nothing wrong with using the occasional goto. "Never ever use goto" is generally promulgated by people who've heard of Dijkstra's article but never read the drat thing.
|
# ? Jun 15, 2008 01:26 |
|
Zakalwe posted:3000 lines is , but there's nothing wrong with using the occasional goto. "Never ever use goto" is generally promulgated by people who've heard of Dijkstra's article but never read the drat thing. I'm skeptical that goto has a valid place outside of perhaps some simple scripting. I challenge you to show me a valid example of goto use in modern object oriented code.
|
# ? Jun 15, 2008 01:31 |
|
Zakalwe posted:3000 lines is , but there's nothing wrong with using the occasional goto. "Never ever use goto" is generally promulgated by people who've heard of Dijkstra's article but never read the drat thing. Gotos have no place in OO (or really any kind of structured) programming. Maybe you'd feel more at home with fortran?
|
# ? Jun 15, 2008 01:38 |
|
Factor Mystic posted:I'm skeptical that goto has a valid place outside of perhaps some simple scripting. I challenge you to show me a valid example of goto use in modern object oriented code. Two that come immediately to mind are breaking out of nested loops in C/C++/C# and cleaning up/freeing resources upon failure in environments that do not provide exceptions. I've used them when I've written parsers too as there was no other clear way of providing similar functionality. Linus Torvalds addresses the use of "goto" in the Linux kernel with some good points here. Yes, they can turn code into an unreadable mess but, sometimes, they can also make code more readable and more intuitive. edit: I'm inclined to think that people who believe that "goto" has no place in modern programming languages have not been programming for long enough.
|
# ? Jun 15, 2008 01:43 |
|
ehnus posted:Two that come immediately to mind are breaking out of nested loops in C/C++/C# and cleaning up/freeing resources upon failure in environments that do not provide exceptions. I've used them when I've written parsers too as there was no other clear way of providing similar functionality. DING DING DING.
|
# ? Jun 15, 2008 01:51 |
|
Factor Mystic posted:I'm skeptical that goto has a valid place outside of perhaps some simple scripting. I challenge you to show me a valid example of goto use in modern object oriented code. They're useful in C for cleanup in the case of errors, and they're usually more readable than the alternatives. Other than that, I don't know that I've ever used them for anything else, and in that case they usually aren't necessary or all that useful in languages with exception handling capabilities.
|
# ? Jun 15, 2008 01:52 |
|
ehnus posted:Two that come immediately to mind are breaking out of nested loops in C/C++/C# The one thing I did like about PHP was that they offer the break X construct that lets you break out of nested loops as far as you want.
|
# ? Jun 15, 2008 02:22 |
|
Ugg boots posted:The one thing I did like about PHP was that they offer the break X construct that lets you break out of nested loops as far as you want. Until you add another loop and WHOOPS, you're not where you think you should be.
|
# ? Jun 15, 2008 02:27 |
|
tripwire posted:Gotos have no place in OO (or really any kind of structured) programming. Maybe you'd feel more at home with fortran? There is the interesting paper "Structured programming with Gotos" by donald knuth. http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf The horror of goto is using it in place of while, for and other looping and structured constructs. However there are occasions where a direct jump is needed and cannot be elegantly done with the existing constructs. Even so knuth does suggest that goto not be used in high level languages. Edit: Perl had the nice thing of goto &function which was occasionally useful, and also allowed you to label loops so you could do break LOOP_NAME
|
# ? Jun 15, 2008 02:33 |
|
tripwire posted:Gotos have no place in OO (or really any kind of structured) programming. Maybe you'd feel more at home with fortran? Here's a nickel, kid, go buy yourself a C book. Zakalwe posted:Until you add another loop and WHOOPS, you're not where you think you should be. Modern (non-lovely *cough*) languages like Java and Perl provide labeled loops and ways to break out of them, so that removes one of the two remaining use cases for gotos nowadays, and exceptions remove the other one. floWenoL fucked around with this message at 04:19 on Jun 15, 2008 |
# ? Jun 15, 2008 04:15 |
|
tef posted:Perl had the nice thing of goto &function which was occasionally useful, and also allowed you to label loops so you could do break LOOP_NAME Why the past tense?
|
# ? Jun 15, 2008 09:43 |
|
floWenoL posted:Here's a nickel, kid, go buy yourself a C book. break my_label is no different than goto my_label as far as breaking out of loops is concerned. It just removes the functionality of one "evil" and sticks it in another.
|
# ? Jun 15, 2008 14:20 |
|
Zakalwe posted:break my_label is no different than goto my_label as far as breaking out of loops is concerned. It just removes the functionality of one "evil" and sticks it in another.
|
# ? Jun 15, 2008 14:42 |
|
zootm posted:This is largely correct but the essential point here is that goto should be limited to the point where execution paths can be easily determined. Gotos within local scope for breaking out of loops and the like are theoretically fine, but jumping between functions, jumping to arbitrary points to emulate flow control, and so on is craziness. There's definitely valid uses within C from what I've seen, though. Agreed. Here's another coding horror. A student of mine refused to use a for loop. He wrote everything as a while loop for(int i=0; i<5; ++i){ do_stuff(i); } was int i=0; while(i<5){ do_stuff(i); ++i; } Now they'll compile down to the same code 99.99% of the time, but it takes up more space, reads strangely to anyone else and the iterator now has scope outside of the loop. I never got a satisfactory answer from him as to why he did this.
|
# ? Jun 15, 2008 14:58 |
|
zootm posted:This is largely correct but the essential point here is that goto should be limited to the point where execution paths can be easily determined. Gotos within local scope for breaking out of loops and the like are theoretically fine, but jumping between functions, jumping to arbitrary points to emulate flow control, and so on is craziness. There's definitely valid uses within C from what I've seen, though. Amen. I can't remember when I've ever used a goto, but specifically for jumping out of multiple levels of loops/switches it is pretty much the only solution other than possibly a return statement in some languages (yes in OO-code too). Multi-level or labled breaks are great, but again, unfortunately not all languages have that option (*cough* C, C++). In those cases, goto can be the "correct" thing to do. Don't get caught into a religious hatred of a particular language feature; it's the naive way of becoming a better programmer. Prematurely ruling out a tool like goto may help you decide more quickly on an implementation for whatever it is you are trying to do since you are decreasing your number of options, but sometimes you may be needlessly throwing away the perfect tool for the job. I'm an atheist, deal with it. Zakalwe posted:Here's another coding horror. A student of mine refused to use a for loop. He wrote everything as a while loop If that's the worst of your problems when teaching a programming class then you're doing a very good job :p
|
# ? Jun 15, 2008 17:03 |
|
Zakalwe posted:
It probably made more sense to him but he couldn't express why or how. That's sad, because I believe a majority of problems people have with code stem from an inability to delineate the nature of their thinking and the problems their thinking attempts to solve.
|
# ? Jun 15, 2008 18:53 |
|
3rd year college level CS course, not a general programming course I'm afraid. The kid was very bright, but I got an air of "self-taught programmer" from him which would probably explain why he did things that way. The same course, although not the same person, yielded the above SIMD 1/1 and y=x*1 code snippets. I know I've been guilty of the same thing. When learning C years ago (self taught) I had a habit of using (*foo).bar rather than foo->bar which some people would call horrific.
|
# ? Jun 15, 2008 22:46 |
|
Zakalwe posted:I know I've been guilty of the same thing. When learning C years ago (self taught) I had a habit of using (*foo).bar rather than foo->bar which some people would call horrific. Hey, at least you knew how to use pointers.
|
# ? Jun 15, 2008 23:42 |
|
Gotos are a better way of cleaning up in error conditions than big nested ifs in situations where exceptions either are not available or cannot be used for reasons such as performance. This is essentially Linus' argument.
|
# ? Jun 17, 2008 17:49 |
|
Here's a coding horror, buttbot! ()Zakalwe posted:there's nothing wrong with using the occasional goto Zakalwe posted:the occasional goto Zakalwe posted:occasional goto Zakalwe posted:BOOK DEPOSITORY You heard it here first, folks, liberal use of goto endorsed by professional programmers!
|
# ? Jun 17, 2008 18:55 |
|
Speaking of gotos, I ran across this today when diagnosing a crash.code:
|
# ? Jun 17, 2008 19:07 |
|
Error handlers are just another form of control structure!code:
|
# ? Jun 17, 2008 21:31 |
|
Randomosity posted:I want to kill the people whose code I now maintain. And wtf is an 'appaplexy'
|
# ? Jun 17, 2008 21:46 |
|
Randomosity posted:I want to kill the people whose code I now maintain. And wtf is an 'appaplexy' An application-induced apoplexy.
|
# ? Jun 17, 2008 22:20 |
|
floWenoL posted:Modern (non-lovely *cough*) languages like Java and Perl provide labeled loops and ways to break out of them, so that removes one of the two remaining use cases for gotos nowadays, and exceptions remove the other one. Wow, I feel stupid. I've been programming in Java for like 5 years and I had no idea it had a labeled break. That would have saved me some hassles.
|
# ? Jun 17, 2008 22:39 |
|
floWenoL posted:Modern (non-lovely *cough*) languages like Java and Perl provide labeled loops and ways to break out of them, so that removes one of the two remaining use cases for gotos nowadays, and exceptions remove the other one. Whoa, whoa, backup. Are you saying Java isn't a lovely language?
|
# ? Jun 17, 2008 22:46 |
|
That Turkey Story posted:Whoa, whoa, backup. Are you saying Java isn't a lovely language? Oh come on when is this poo poo going to end? It's not that bad.
|
# ? Jun 17, 2008 23:21 |
|
Randomosity posted:Error handlers are just another form of control structure!
|
# ? Jun 18, 2008 03:19 |
|
code:
Every usage of either of these functions looks like this: code:
|
# ? Jun 18, 2008 07:52 |
|
On the subject of exception based control flow:code:
|
# ? Jun 18, 2008 10:13 |
|
Zombywuf posted:On the subject of exception based control flow: haha oh god... at least that gets creativity points. Who needs RTTI when you have exceptions?
|
# ? Jun 18, 2008 14:36 |
|
int newNum = Utils.PrestoChango(x);
|
# ? Jun 18, 2008 15:09 |
|
Smackbilly posted:haha oh god... at least that gets creativity points. Who needs RTTI when you have exceptions? On the subject, I got to extend a code base for a student project that did stuff like this: code:
*Class functions would throw exceptions on completion (or error) to be caught by other class functions. There were also a few places where whoever wrote it clearly could have used a switch if it had occurred to him.
|
# ? Jun 18, 2008 23:32 |
|
Munkeymon posted:On the subject, I got to extend a code base for a student project that did stuff like this: Exceptions are like goto, only they're just "gosomewhere".
|
# ? Jun 19, 2008 23:50 |
|
|
# ? May 16, 2024 18:54 |
|
more falafel please posted:Exceptions are like goto, only they're just "gosomewhere". Plus they're objects and can carry a payload of other objects. It's the perfect fusion of functional and object oriented 'features' in one disturbing package.
|
# ? Jun 20, 2008 17:26 |