- 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
Not the first time I've seen someone mystified by Perl's spaceship operator. And as far as I know every single Perl distribution comes with complete and clear documentation.
As someone who started with perl long before it had strict, I gotta agree with the last one. If I wanted to write clean and polished code I wouldn't be using perl in the first place.
Admin
Its pretty easy for it to happen, but it is kind of lame to write code to protect against it.
sysDraw *psd = NULL;
psd->close();
This will call sysDraw::close() function and this will be NULL. You should be tracking down why you are calling the function with a null pointer. Adding a if this equals null is just a bandaid on the problem.
Admin
WTF Batman fails because first, his name is WTF Batman, so it's impossible to take him seriously, and secondly, he used the signature feature, Gene actually SIGNS his post each time.
Also, this makes you the troll, since your only purpose was to provoke a response from me or someone like me.
Try harder!
Admin
Yes... In theory it's too late to test for that, because in order to get to that return you have already technically dereferenced a null pointer and invoked undefined behavior. In practice, the behavior that you'll actually get (assuming it's not something like a virtual function) is that the call will succeed with a null this pointer.
A better solution than just returning would be to crash hard so it's easier to find the bad call so you can add the null check there or whatever. Then again, if you're about to ship the code somewhere undebugable, I suppose this is a sensible panic action for a "close" function.
Admin
Oh yeah, not necessarily a null this pointer. If inheritance is involved, you may end up with a pointer that has been adjusted so that it won't compare equal to null. Basically, checking for null inside the function is fragile.
Admin
I don't know what MaybeAutoDelete() do, but in the open source Gallery 2 there's a function begin with "maybe" which do the following:
Admin
Admin
Admin
I don't care whether his sig was generated by a modified toaster, it's still f'ing annoying
Admin
The Koders search also turned up this nice bit from the Moz source:
Admin
Now I'm scared. This morning I wrote:
Is there anything scarier than seeing something which looks like your own code on the daily WTF?
(In my case, it was code written out of the office when I didn't have a live database to check how it deals with empty strings)
Admin
That's not necessarily true, depending on when the code was written. VC 5 has a buggy code generator that would strip the this pointer in some cases, during optimization; especially during callbacks. After spending a few days trying to hunt down this particular bug, I wrote a pretty nifty exception catch that would flag the debugger locally, and blow up all over the place if it errored.
The key code boiled down to if (!this) __asm int 3; at the beginning of a particular message handler. (Ok, it doesn't seem that nifty when I strip it down, admittedly... but that was effectively what got built into the function)
The result? With identical builds I never got the interrupt locally. I shipped with a note to the company I developed it for that there was a "Known bug, and if it errored to give me a call with debugging information." This was built, primarily, for a software development shop, so I figured "You know, this guy's going to know when it crashed and dumps to record the dump, start up his debugger, give me a call and ask WTF?"
6 years later I've not been able to duplicate it again with that tool; the client never called, and over lunch with some of the guys at the company I developed it for, they said the solution fixed a runtime error in what they believed was also a compiler bug -- I checked that code, and it looked fine to me also.
It makes perfect sense that this code is reasonable if originally written on buggy implementations. VC5 was notorious for this and other numerous optimization errors, generally some slight code change (such as if (!this)) would be enough to straighten things out again.
Admin
i agree, i cringe as well
Admin
Yup! THAT's why I use Gentoo. ;)
Admin
Another possiblity is that the function might get called while the object is in the destructor - in that case, things tend to go splat really badly.
Admin
The Real WTF is (TM)......
That he is using multiple instances of the single line comment // instead of putting all comments within a block of
/*
... .... */
Admin
Admin
You use line-comments within blocks you might want to comment out with / ... */ later. Also, you might want to write several lines of comments behind the code, and then you can't use //.
Super-Galactically Mega Co-Starring,
MIKADEMUS
Admin
you know what i think is reduntant. some dickhead constantly going on at someone for doing this.
personally, i prefer Gene's input. He adds comments that actually refer to the topic.
They are generally intelligent responses.
If his preference is to write that, whos to stop him? you?
Gene, i say keep it up. If it makes him cringe, do it multiple times in one post -
we might end up getting him riggling on the floor in some sort of a semi-epileptic fit.
Admin
I you could do it with one hand, you could play Chopin
Admin
Try that again. . .
If you could do it with one hand, you could play Chopin
Admin
It's not just you. It makes me want to sign my posts:
Seruptitiously,
Rich
Admin
I thought OTP was One Time Perl, which commenting out 'use strict;' is the surest way to achieve.
Admin
I can. But it feels really unnatural. ;)
Admin
"Its pretty easy for it to happen, but it is kind of lame to write code to protect against it. sysDraw *psd = NULL; psd->close(); This will call sysDraw::close() function and this will be NULL. You should be tracking down why you are calling the function with a null pointer. Adding a if this equals null is just a bandaid on the problem." I've done something like that. Was passing a member function to a C library as a callback (to get messages from it, nothing critical) but I set this up in the constructor, so it was possible to get a callback occuring before the constructor finished (said library being multithreaded). It was horrible code though.
Admin
Admin
hahahah no comments!!
Admin
Aw, and I almost thought this "Commentator" was actually available.
Seems like I'll have to emulate the verbosity=10,relevance=0,selfimportance=10 myself.
Admin
I love it.
Admin
Monday, October 14th, if I recall correctly. At around 8:45AM, GMT.
Admin
T'was Sunday the 21th of October actually, but around 8:45AM indeed, for God liked to get work done early in the morning while he was feeling fresh.
Admin
FYI, the 4004 BC thing is religious nutjobbery from about one hundred years ago. Today's religious nutjobs are saying that bloodclotting is unlikely to evolve without intelligent help because it is irreducibly complex. The scaffolding counterargument claims otherwise. As far as I know, there is no longer a debate about the overall empirical dating and it has shifted into the realm of "the dice are loaded", "are not", "are too", "are not", "are too", "dee two".
Admin
All of you are forgetting one thing. Your Flux Capacitor.
Admin
I believe that it was on a Monday. Six days later, he rested.
Admin
Try
$script ||= 0;
in the future.
Admin
Someone explained the kung fu death grip thing a while ago in Slashdot. Apparently, it's part of the garbage collection mechanism in event handlers - some operations mess with the reference counts, and if you want to make sure something isn't deallocated while you aren't looking and you need to keep the object around, you apply the kung fu death grip on the thing.
And that's all I know about Mozilla source code. =)
And, bleh, #use strict; is just asking for trouble. Definitely saying "Please don't whine about my sloppiness." It is every Perl coder's duty to Read the fine Camel Book if you get some mysterious errors from your newbieish, messy code. The book is very informative indeed. use strict; is the first step towards making the code good.
Admin
Assuming we are referring to the Jewish/christian/Muslim God. (which are essentially the same, though none will admit the others know anything about him)
The universe was created on a Sunday (the sabbath is Saturday, not Sunday!), and God started in the Evening. (What time zone is not specified, though usually Jerusalem time is assumed. Some would guess Garden of Eden time but they don't know where that is. Might be other theories as well)
Reference (KJV): Genesis 1:5: And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day. Genesis 2:2: And on the seventh day God ended his work which he had made; and he rested on the seventh day from all his work which he had made.
Admin
They can be. It depends heavily on whether you 'use strict;'.
Is the alternative 'use eldritch;', 'use cyclopean;' or 'use rugose;'?
Admin
I don't even write shit like that in "C" any more.
for(p=buffer,q=p;*q&&*(p+=(*q++!=TOK_END))!=TOK_END;prepare(&p,&q))
continue;
Admin
Some people here are seriously lacking in the Pratchett/Gaiman department...
Admin
I have read and own every Pratchett up to and including Night Watch. Who is Gaiman?
Admin
You've never heard of Good Omens?
Admin
Unto God, a Thousand Years is as a Day, a Day is as a Thousand Years.
So whos to say that things werent more laid back back then? The Earth took its time spinning about, as did everything else.
On the jewish/christian/muslim thing. Are Christians executing Muslims in the name of this 'common' god.
(I also understand this is not done by all muslims. i have nothing against them. dont misread my thoughts.)
But no more religious talk from me. You dont want to go down that path. Lets keep it Coding related people.
Regards,
Sao.
Regards,
Sao.
Regards,
Sao.
(Convulse all you signed-post-alergic people out there, Convulse!!!)
Admin
Neil Gaiman, author of the Sandman series. He collaborated with Pratchett on the book 'Good Omens'.
http://www.amazon.com/exec/obidos/search-handle-url/ref=br_ss_hs/104-2808118-5695143?platform=gurupa&url=index%3Dstripbooks%3Arelevance-above&field-keywords=neil+gaiman&Go.x=0&Go.y=0&Go=Go
should help.
Admin
You obviously haven't since the quotes and reflections on the creation of the earth in 4004 come from Good Omens, written in 1990 in collaboration between Terry Pratchett and Neil Gaiman
An english author of science fiction books and comics, very well known in the US for his Sandman serie (well known enough that he's credited before Pratchett in the US edition of Good Omens, while Pratchett is usually credited first e.g. the UK and french editions), he's the author of the recent American Gods (2001) and Anansi Boys (2005), and -- even though I doubt you care the least about it -- a friend of singer Tori Amos.
Admin
Oops. I meant to say every discworld up to NightWatch. I haven't read any Pratchett apart from discworld.
Admin
You don't want to lose the pointer, so you use the ku-fu death grip on it. It makes perfect sense.
Admin
This thread has some of the geekiest replies I've ever read! You guys know who you are...
Admin
they did a few centuries ago
Admin
Then I'd really recommend reading Good Omens, it's good.
And the Tiffany Aching arc (The Wee Free Men and A Hat Full Of Sky, with at least 2 other upcoming books. It's like Harry Potter, but good.). Going Postal is also very good (and much funnier than Night Watch, which is kind of apart from the whole Discworld collection), and extremely geeks-oriented.