Darren Winsper ([info]dwinsper) wrote,
@ 2006-11-28 16:59:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
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.



(10 comments) - (Post a new comment)


[info]newsbot3
2006-11-28 05:09 pm UTC (link)
insanely retarded sounds about right.

(Reply to this)


[info]erunamo
2006-11-28 05:17 pm UTC (link)
That sounds suitably deranged enough for VB. Just hope I never have to work with it!

(Reply to this)


[info]nmitchell
2006-11-28 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...

(Reply to this) (Thread)


[info]andrew_j_w
2006-11-29 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.

(Reply to this) (Parent)


[info]dwinsper
2006-11-29 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.

(Reply to this) (Parent)(Thread)


[info]nmitchell
2006-11-29 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.

(Reply to this) (Parent)(Thread)


[info]dwinsper
2006-11-29 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.

(Reply to this) (Parent)


[info]nmitchell
2006-11-29 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.

(Reply to this)

Thank You for site
(Anonymous)
2007-08-27 06:34 am UTC (link)
Thank you for your site. I have found here much useful information.
Good site ! ;)

(Reply to this) (Thread)

Re: Thank You for site
(Anonymous)
2007-08-27 02:18 pm UTC (link)
Hi,

My name is horney Melissa. I like your site. I hope you like mine too! http://www.melissatakesdonkeycockineveryhole.com/

(Reply to this) (Parent)


(10 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…