Thomas (boggyb) wrote,
Thomas
boggyb

Today's discovery is that Perl doesn't have a null value. In the following code, the if statement will throw an error:

undef $foo;
if ($foo == 2)
{
    # do something
}


This is because Perl doesn't actually have a concept of null. The nearest thing is an undefined variable (undefined in the sense that the variable does not exist, not in the sense that the variable exists with unknown contents), except you can't directly use it with comparisions or logical operators. I like VB, as it does have such a thing:

Dim Foo
Foo = Null
If Foo = 2 Then
    # do something
End If


In VB, Null is a distinct value from zero (the classical C representation), and does pretty much what you expect. There are also distinct values for Nothing (an object variable that does not refer to an actual object, like a C null pointer but with error handling), and Empty (an optional parameter that was not provided). 'Course, to use these you do need to use Variants which have a performance hit, but it's not really significant anymore in this age of multi-gigahertz processors and it makes database work nice.
Subscribe

  • Skyward Sword HD: for SCIENCE!

    One thing I've noticed from playing through Skyward Sword HD is how... underwhelming the skyward strike appears, at least to begin with. It takes a…

  • Summon giant frog?

    Impa has a rather unusual finishing move in Hyrule Warriors Calamity...

  • King Dorephan = Boss Nass?

    Is it just me, or does King Dorephan from Hyrule Warriors: Calamity remind anyone else of Boss Nass from Star Wars: Episode 1? I was slightly…

  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments