in reply to RFC: Verify Interpreter and Language

Do you distinguish between "" and undef/null? Because in Perl, they're not exactly the same, nor are they in SQL, and in Perl they're even hard to test without warnings. I hope your system is more flexible in doing the test. I like Javascript's syntax, where you can directly compare to null.

You said:

Variables do not need declaration, similar to perl without using strict. They default to 0.
Is the default "0" or "", when treated as string? Is it the same as undef/null?

p.s. Your perl pseudocode is off. "my" is written in all lowercase, and

$interpreter( \%bind_variables )
needs an arrow:
$interpreter->( \%bind_variables )

Replies are listed 'Best First'.
Re^2: RFC: Verify Interpreter and Language
by exussum0 (Vicar) on Feb 10, 2006 at 04:09 UTC
    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. :)

      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. :)