The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Uninitialized versus auto-initialized variables

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Uninitialized versus auto-initialized variables Posted: Sep 15, 2004 7:30 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Uninitialized versus auto-initialized variables
Feed Title: David Buck - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/buck-rss.xml
Feed Description: Smalltalk can do that
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From David Buck - Blog

Advertisement

My blog article Bug rates in a Smalltalk project prompted a discussion on uninitialized variables. I thought I'd bring the discussion into its own thread here.

I said I doubted that compilers can detect uninitialized variables except in trivial cases. Isaac Gouy showed an example from Nice and asked if my doubts were answered.

Actually, they aren't. In the Nice example, it handled the problem by forcing you to initialize the variables. C# auto-initializes the variables. What I was looking for was the ability to leave the variables with a nil value. This way, I can detect the error that they were not assigned a proper value at the time I need to use them.

This is not a limitation of static typing at all. It's a limitation of primitive types which is quite different. Statically typed languages can have variables that can contain nil or a boxed type. They typically can't have a variable that can contain nil or a primitive type.

Read: Uninitialized versus auto-initialized variables

Topic: Discovering Better Code Previous Topic   Next Topic Topic: On the IRC

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use