?

Log in

No account? Create an account
entries friends calendar profile www.winsper.org.uk Previous Previous Next Next
Is VB.Net retarded? Let's find out! - One Man's Trek Into The Abyss
So you think you can tell Heaven from Hell?
dwinsper
dwinsper
Is VB.Net retarded? Let's find out!
Right, time for the answer to my previous riddle. The output of the code I posted is...a NullReferenceException! Yes, that's right folks, VB.Net will try to dereference a null (Nothing) reference despite the fact that you're blatantly checking for it and taking steps to prevent it. This is because VB.Net will evaluate both code paths in the inline-if statement. Thus, VB.Net is retarded, or insane, whichever you fancy.
8 comments or Leave a comment
Comments
newsbot3 From: newsbot3 Date: November 28th, 2006 05:09 pm (UTC) (Link)
insanely retarded sounds about right.
erunamo From: erunamo Date: November 28th, 2006 05:17 pm (UTC) (Link)
That sounds suitably deranged enough for VB. Just hope I never have to work with it!

nmitchell From: nmitchell Date: November 28th, 2006 07:22 pm (UTC) (Link)
Iff in VB (and VB.net) is a function, not internal to the compiler. Functions in VB are strict, hence the behaviour is entirely reasonable. Things like && have to be written specially and be internal.

It does go to show how silly strict semantics are though...
andrew_j_w From: andrew_j_w Date: November 29th, 2006 08:56 am (UTC) (Link)
The fact it is internal doesn't explain why though. Either the function should be special cased to make it lazy, or not added at all.

It's insane to have a function like that.
dwinsper From: dwinsper Date: November 29th, 2006 09:46 am (UTC) (Link)
But but If retarded Is Null Or retarded.ToString() = "nigger please!" also throws NullReferenceExceptions!

P.S. Yes, I know about OrElse, it's still retarded behaviour.
nmitchell From: nmitchell Date: November 29th, 2006 10:08 am (UTC) (Link)
Indeed. But remember that C has & and &&, and I have seen loads of CGO students typing & when they mean &&. Its exactly the same issue.

What is MOST retarded is that VB didn't have OrElse, or any short-circuiting boolean operators. VB.Net in that respect is a fix.
dwinsper From: dwinsper Date: November 29th, 2006 10:21 am (UTC) (Link)
The choice in syntax in C isn't that great for those operators, sure, but the behaviour in VB.Net is just plain stupid, considering it has turned 5 lines of code I had into 15 because I had to replace my IIf constructs with "If ... Then ... Else ... End If" and thanks to VB.Net's lack of ability to have multiple statements on one line, that block of code just looks terrible.
nmitchell From: nmitchell Date: November 29th, 2006 09:36 am (UTC) (Link)
I can't speak for VB.Net (only VB), but it was never internal, it was in a module of useful functions. VB keywords wouldn't have brackets, so it is obviously a function, even if that semantics of that are obviously crazy.
8 comments or Leave a comment