On Fri, Sep 23, 2016 at 2:27 AM, Peter TB Brett <peter.br...@livecode.com> wrote: > > "" isn't "the absence of a string", it's a string that's 0 characters long. > Being able to use it as an array key is important for being able to > represent real-world data in an array.
It's an important point that "", a 0 character string is not the same as NULL because we as humans often 'see them' as the same. Unfortunately one of the great features of LC, the fact it's typeless and it auto converts integers/strings/dates back and forward as we need them, also means that occasionally it makes the same mistake we make: In the msg box - 8 lines all ending with msg: put "empty = " & quote & quote & " is " & (empty = "") into msg put cr & "empty = NULL is " & (empty = NULL) after msg put cr & "navtiveCharToNum(empty) = " & nativeCharToNum(empty) after msg put cr & "natvieCharToNum(" & quote & quote & ") = " & nativeCharToNum("") after msg put cr & "nativeCharToNum(NULL) = " & nativeCharToNum(NULL) after msg put cr & "Therefore:" after msg put cr & "navtiveCharToNum(empty) = nativeCharToNum(NULL) is " & (nativeCharToNum(empty) = nativeCharToNum(NULL)) after msg put cr & "So although an empty string is NOT the same as the NULL character, in some cases LC treats them the same" after msg or to put it another way, "" and empty do not roundtrip In the msg box: put numToNativeChar(nativeCharToNum(empty)) = empty --returns false When dealing with databases, tracking the difference between NULL and empty and "" can be a real pain. Is this a feature or a bug? To me the advantages of 'typeless' far outweigh the 0.001% of times I hit this gotcha. _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode