Type conversions and Nulls

  • I got caught by the Null. I work as a Programmer more often than not where some Languages automatically initialise a Variable at declaration time. The ones that don't tend to just leave the Variable with whatever is in its memory location. I would prefer Null as a default in these instances rather than garbage.

  • David Conn (3/6/2013)


    The ones that don't tend to just leave the Variable with whatever is in its memory location.

    Yikes, not sure I know (or knew or remember) which might do that. To which were you referring?

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • C. This was my first encounter with uninitialised variables.

    When I declare an Integer for example I expect its value to be 0.

    At least in T-SQL we can now give a Value on the Declare statement.

  • David Conn (3/6/2013)


    C. This was my first encounter with uninitialised variables.

    Thanks. I am pretty sure that aspect of C "fell off my memory queue" a long time ago 😛

    At least in T-SQL we can now give a Value on the Declare statement.

    I like that too. We didn't have to worry about garbage in an uninitialized variable but that piece always seemed like one of the more obvious gaps in the language. Now that it is there the language feels that much more fluid and aligned with most of the other languages I work with, which is nice.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • I was considering the value of null. Apparently, I mistakenly thought (null = 0) would return false (not unknown) and then the not operator would change it to True thereby executing the then clause instead of else.

    +1

Viewing 5 posts - 46 through 49 (of 49 total)

You must be logged in to reply to this topic. Login to reply