in reply to Re: RFC: Verify Interpreter and Language
in thread RFC: Verify Interpreter and Language

I've thought about adding a builtin called "defined" or "isnull" that will check if a bind variable, or internal is null. I don't want to get in the mess of passing nulls around unless there's good reason. A real life valid example if it were to actually allow the assignment vs the comparison of undefs...

I'll fix my psuedocode tomorrow. I did it in word. Stupid grammar checker. :)

  • Comment on Re^2: RFC: Verify Interpreter and Language

Replies are listed 'Best First'.
Re^3: RFC: Verify Interpreter and Language
by bart (Canon) on Feb 14, 2006 at 17:32 UTC
    Hmm I don't seem to have made my position clear. What I mean was, occasionally in data, an empty string and NULL are equivalent. Occasionally, 0 and NULL, or 0 and "" are equivalent. Effectively testing this in Perl is a bit of a pain, and in SQL it's even a lot worse because
    SELECT * FROM mytable WHERE foo=foo
    will not show the records where foo is null. Purists might say this is how it should be, but I think it's just not very practical.

    It'd be nice if you provided a simple means to test if a value is, say, NULL, 0 or "", perhaps using something like in (as in Mysql):

    if($foo in (0, "", undef)) ...

    I'm actually not even sure that NULL is a valid value for the IN list in Mysql...

      I see what you mean. This is what I provide. Give me your opinion on when I can tweak it, or reasons to change it.

      == works on strings and numbers in Verify.

      "" == 0, 1 == "1", "2" == 1+1 would all return true.

      "a0" == 0 would return false, since a0 is not convertable to a number.

      If you refer to a variable that does not exist, the empty string is returned. So doing something like "" == x, where x isn't defined, would return true.

      I'm convinced to add isDefined/isNull, similar to perl's defined.

      p.s. Thanks for the feedback. Whole point is to get some tweaking in on this before I shoot myself in the foot. :)