- 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
yeah, I know... I failed english in high school... twice. That's why i'm a programmer!
my problem was with this whole part "the guys whose code is so horrible that it makes this web site are not."
maybe it just needs some punctuation... like:
the guys, (whose code is so horrible) that it makes this web site, are not.
now that i can understand. but still the "it" doesn't belong and it should be make, not makes...
the guys, (whose code is so horrible) that make this website, are not.
ahh, much better ;)
Admin
Truthiness at its best!
Everybody knows the correct way to add FileNotFound is by subclassing Bool. Then you can add other fields, while you're at it.
Admin
CAPTCHA = stfu
Admin
The Meta-WTF?! is that people who fail classes in grammar and syntax think that makes them qualified for career in programming. Programming is all about grammar and syntax, just not the "King's English" kind.
captcha: error (almost made me delete my post)
Admin
In probability, the cat is alive or dead, with no state in between; while in fuzzy logic, the cat could be very ill, or maybe just have a hairball.
Admin
Or the cat could be trapped inside a box and opening the box will kill the cat. To an external observer the cat is in an indeterminate state which cannot be determined exactly (go Schroedinger!) without destroying that state. Sorta like opening a file to determine the last access time...
Admin
The real WTF is that the opening brace is on a seperate line, when everyone knows that it should look like this:
enum Bool {
...
};
Admin
Shouldn't the 'that' be outside the braces? ie
'(The real WTF) is that [[I'm unemployed] and [((the guys) whose code is [so horrible that it makes this web site]) are not{unemployed}]].'
Admin
That is why you should always use the isTrue() function!
Admin
In response to Reeeeeaaaaaaly?
42 is the Answer to the Ultimate Question of Life, the Universe and Everything.
Unfortunately nobody knows the Question.
Loose paraphrasing of Douglas Adams' hilarious and irreverent science fiction parodies such as "The Hitchhiker's Guide to the Galaxy", "The Restaurant at the End of the Universe" and "Life, the Universe and Everything".
Admin
Grammar and syntax? Why differentiate the two?
The structure of a language (its syntax) is governed by the rules of its grammar just like its morphology, phonology, phonetics, semantics, pragmatics and to a certain extent semiotics. While computer languages have a subset of natural language's features, it's all about the grammar.
Admin
true > 0
false < 0
error == 0
You haven't seen this before?
Error does not indicate false, but rather that the test failed to execute.
Bool is possibly a poor name for this enum, but it's not that big a deal
Admin
<FONT face=Tahoma>I like those pop-up Potpourries! Gives me lots of laughs...
Too bad we see them less now...
"Do you want to apply this isolated undo step as a new edit? This might break the space continuum..." wow... :D
</FONT>
Admin
LOL. Superb. In fact, why not make bool a pattern? I think it deserves that status.
Admin
if (False) {
mention_that_brillant_is_actually_French_for("brilliant");
}
Admin
nononono... you've just changed the meaning of what the original poster was saying.
you may find it easier to understand if you read
as
Admin
Being a team player is much more important than having skills. Think of Paula: She was a team player, until the very end!
Admin
Fuzzy logic is not probability. A fuzzy variable can have multiple values at once. A random variable in probability has only one value, but with different probabilities.
Admin
"With most Americans (including myself) enjoying a long, Indepdence Day Weekend"
Yanks eh? Any excuse...
Admin
That is not the correct question.
It may be possible to compute the applicable question, but unfortunately no sufficiently powerful computer is in existence at this time. You might want to build one.
Admin
Or better yet, celebrate Christmas on October 30th. Because:
24 dec == 30 oct
Admin
Which might make it worthwile to add type conversion to a proper bool...
class Bool
{
public:
typedef enum {True, False, FileNotFound} BoolEnum;
BoolEnum value;
operator bool() const
{
switch(value)
{
case True:
case False:
return(!value); // You might want to find out why.
case FileNotFound:
throw FileNotFoundError("file not found");
}
}
};
Admin
bool isTrue() {
char true[] = "this is true";
char false[] = "this is false";
if ( something == true )
return 1==1;
else ( something == false)
return 1==2;
else
return open("foobar.txt","rw");//NOTE: dont create this file!
}
--Tei
Admin
Or on Hexember 18th. No, wait...
Admin
As noone seems to have noticed last time, here goes again:
Boolean logic does work on true, false, undefined. Either do the math yourself or look at wikipedia. FileNotFound can, depending on context, be equivalent to undefined.
Anyway, this is valid boolean logic.
PS: Yes, i am aware that there are boolean algebras where unknown is equivalent to false
Admin
Actually, that would be TextNotFound.
Just go to http://en.wikipedia.org/wiki/Boolean_logic then search for the term "undefined" on the displayed Web page. What I get is "Text not found."
Admin
Surely it's better to celebrate Christmas at Halloween, since Dec 25 = Oct 31. Why would you celebrate Christmas on the 24th?
Admin
Three things are certain
Death, taxes, and file not found
Guess which has occurred.
Admin
He celebrates Christmas on Christmas Eve...
Admin
In fact there are 1101 types of people:
Admin
One is the misuse of the term "Boolean" when the thing should be called "Heyting." A "Boolean" can only be either 0 or 1. (Either do the math yourself or look it up in Wikipedia.)
The other one is the data type. If you go beyond Boolean and want to have values other than 0 or 1, then they need to be between 0 and 1, and you can't do that with an enum, or an int for that matter.
So this might work:
typedef enum {False = 0, True = 1} Boolean;
const double Heyting::False = .0;
const double Heyting::ENOENT = .42; // no such file or directory
const double Heyting::True = 1.;
Admin
Yeah, holy cow you REALLY must suck at coding ;)
Admin
Can we see a few samples please?
Admin
/me claps appreciatively.
Admin
It's a bit WTFish that the replies to this WTF are such a mix of
1) People defending/defying bools/trools/whatnot seriously, AGAIN
2) People just goofing around having fun (some VERY funny posts)
3) People making totally off-topic posts
(Ok, 3) checked for me.)
Admin
You are all fools....this is a stroke of Genius: imagine ! You don't have to declare variables for each error code...you just increase the Bool enum type....
Of course , You'll have to compare all values with 0
v= Bool.FileNotFound;
if(v>0) { //error}
else
{//ok
}
What's not to understand? ....
=)) :))))))))
Admin
Can anyone provide a scenario that can not be reduced to 1/0?
Admin
I really wonder if there ever was an attempt that introducing fuzzy logic to programming languages.
Multiples degrees of truth for the win.
captcha: zork
oh my childhood.
Admin
The real WTF is that no WTF's get posted until we computer geeks are supposed to be working. Good thing the computer illiterate bosses don't know this.
Admin
how about
Admin
I'm Canadia.....
argg
do they even know how to program up there?
next time lets see you place all the letters when making a reference to our great country.
or I will send Johnny Pasta over and he will break your legs like spagetti.
I got monday instead of friday.
what I needed was the whole week off tho...
Admin
> when the thing should be called "Heyting."
Damn. Beat me to it.
<font face="Courier New" size="2">public abstract class Heyting {
public final float Top = 1.0;
public final float Bottom = 0.0;
public float leq( float a, float b );
protected float sup( float a, float b ) {
return (leq( a, b ) ? b : a);
}
protected float inf( float a, float b ) {
return (leq( a, b ) ? a : b);
}
public float join( float[] s ) {
int jn = s[0];
if (s.length > 1)
for (int i = 1; i < s.length, i++)
jn = sup( jn, s[i] );
return jn;
}
public float meet( float[] s ) {
int mt = s[0];
if (s.length > 1)
for (int i = 1; i < s.length, i++)
mt = inf( mt, s[i] );
return mt;
}
public float not( float a ) {
return arrow( a, Bottom );
}
public float arrow( float a, float b ) {
if (leq( a, b )) {
return Top;
} else {
return b;
}
}
}
public class WTF extends Heyting {
public final float True = Top;
public final float False = Bottom;
public final float FileNotFound = 0.42;
public float leq( float a, float b ) {
return (a <= b);
}
}
</font>
There. No more WTF.
Admin
Interestingly enough, the fact that you don't know doesn't change the fact that a thing is either true or not true.
Admin
<FONT size=2>Set Jessep = Request.Answers();
Set Kaffee = Request.Answers(True);
If(Kaffee) {
</FONT><FONT size=2> Throw New Truth.UnhandledException(Jessup);
}</FONT>
<FONT size=2>Okay, so it was an obscure joke.</FONT>
<FONT size=2>--
$0.02
</FONT>
Admin
Calling that type Bool gives entirely wrong associations, and the three values are not the whole story here. Names indicating general truth values (True, False) are mixed with a more domain specific name (FileNotFound), adding to potential confusion. How about doing as below instead?
enum Result
{
Success,
Failure,
FileNotFound
};
Admin
Yet another approach, bitmasks
#define FILENOTFOUND_ERROR 1000b
#define OVERFLOW_ERROR 0100b
#define FALSE 0010b
#define TRUE 0001b
#define SUCCESS 0001b
#define ERROR 1111b
#define isError(errorcode) (errorcode & ERROR)
#define isTrue(errorcode) (errorcode & TRUE)
#define isFalse(errorcode) (errorcode & FALSE)
#define isFileNotFound(errorcode) (errorcode & FILENOTFOUND_ERROR)
The nice feature of that, is you can combine errors:
return SUCCESS | FILENOTFOUND_ERROR;
Admin
Bitmaps are used when you have a set of independent boolean states that can happen (or can be set by a user) and you want/need an effective data structure for storing them. Independent here means that in general, any permutation of the bits can be considered being a valid response.
Not so in your example.
Also,
return SUCCESS | FILENOTFOUND_ERROR;
always returns true.
Admin
Doesn't Microsoft do this for ages ?
Microsoft Access checkbox : true, false, unknown ...
Greetz
Admin
It is obvious, sir, that you DO NOT understand binary.
Admin
You can compile this and run. Will return 9, that is.. true, because is noncero. But on this code a function can return a nonzero value, 0x2, that is FALSE.
#include "stdio.h"
#define FILENOTFOUND_ERROR 0x8
#define OVERFLOW_ERROR 0x4
#define FALSE 0x2
#define TRUE 0x1
#define SUCCESS 0x1
#define ERROR 0x15
#define isError(errorcode) (errorcode & ERROR)
#define isTrue(errorcode) (errorcode & TRUE)
#define isFalse(errorcode) (errorcode & FALSE)
#define isFileNotFound(errorcode) (errorcode & FILENOTFOUND_ERROR)
int fun(){
return SUCCESS | FILENOTFOUND_ERROR;
}
int fun2(){
return ERROR | FILENOTFOUND_ERROR;
}
int main(){
printf("Test: %d\n", fun() );
//Will print "Test: 9"
printf("Test2: %d\n", fun2() );
//Will print "Test: 29"
return 0;
}