Re: use "" as an array key

2016-10-04 Thread Bob Sneidar
sqlYoga handles sql NULL by converting them to the string "NULL". When writing 
back to the table it handles that too. the difference in where clauses is that 
you cannot use equal (=) as an operator. You have to use "is". Also I think in 
an insert or update statement in the set clause you have to use the NULL 
constant and not enclose in single quotes 'NULL' which would be the string.

Bob S


On Sep 24, 2016, at 24:35 , Peter TB Brett 
> wrote:

On 24/09/2016 04:26, Kay C Lan wrote:
On Fri, Sep 23, 2016 at 2:27 AM, Peter TB Brett
> 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.

Very confusingly, "null" in LiveCode Script is _not_ the same as "NULL" in SQL.

In LiveCode, "null" is shorthand for "numtochar(0)".

LiveCode Script doesn't really have the concept of "no value at all" that is 
modelled by SQL's "NULL".  Most of the syntax fakes it by using the empty 
string, but unfortunately that doesn't work everywhere.

LiveCode Builder has "nothing", which is a proper "no value".

 Peter

--
Dr Peter Brett >
LiveCode Technical Project Manager

lcb-mode for Emacs: https://github.com/peter-b/lcb-mode

___
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


Re: use "" as an array key

2016-10-04 Thread Bob Sneidar
noticed that too. Doesn't seem to hurt anything. 

Bob S


> On Sep 22, 2016, at 10:58 , Matt Maier  wrote:
> 
> I find myself in want of a YAML library again. Mark posted some functions
> on the forum that I'm debugging
> http://forums.livecode.com/viewtopic.php?f=7=21434
> 
> Something I discovered while debugging is that "" is being accepted as an
> array key.
> 
> It seems like it shouldn't be possible to use the absence of a string as an
> array key. Is it supposed to work that way? I'm using 8.0.1 on Windows.
> ___
> 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


___
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


Re: use "" as an array key

2016-09-24 Thread Peter TB Brett



On 24/09/2016 04:26, Kay C Lan wrote:

On Fri, Sep 23, 2016 at 2:27 AM, Peter TB Brett
 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.


Very confusingly, "null" in LiveCode Script is _not_ the same as "NULL" 
in SQL.


In LiveCode, "null" is shorthand for "numtochar(0)".

LiveCode Script doesn't really have the concept of "no value at all" 
that is modelled by SQL's "NULL".  Most of the syntax fakes it by using 
the empty string, but unfortunately that doesn't work everywhere.


LiveCode Builder has "nothing", which is a proper "no value".

  Peter

--
Dr Peter Brett 
LiveCode Technical Project Manager

lcb-mode for Emacs: https://github.com/peter-b/lcb-mode

___
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


Re: use "" as an array key

2016-09-24 Thread Matt Maier
Thanks for explaining that gotcha in detail.
I've had a few problems before when I relied on the 99% awesome debugger
and variable watcher only to find out that it wasn't showing me the many
characters that exist, and affect code, but are technically invisible.

On Sat, Sep 24, 2016 at 6:26 AM, Kay C Lan  wrote:

> On Fri, Sep 23, 2016 at 2:27 AM, Peter TB Brett
>  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
>
___
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


Re: use "" as an array key

2016-09-23 Thread Kay C Lan
On Fri, Sep 23, 2016 at 2:27 AM, Peter TB Brett
 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


Re: use "" as an array key

2016-09-22 Thread Peter TB Brett

On 22/09/2016 18:58, Matt Maier wrote:

I find myself in want of a YAML library again. Mark posted some functions
on the forum that I'm debugging
http://forums.livecode.com/viewtopic.php?f=7=21434

Something I discovered while debugging is that "" is being accepted as an
array key.

It seems like it shouldn't be possible to use the absence of a string as an
array key. Is it supposed to work that way? I'm using 8.0.1 on Windows.


"" 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.


Peter

--
Dr Peter Brett 
LiveCode Technical Project Manager

lcb-mode for Emacs: https://github.com/peter-b/lcb-mode

___
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


Re: use "" as an array key

2016-09-22 Thread Richard Gaskin

Matt Maier wrote:

> Something I discovered while debugging is that "" is being accepted
> as an array key.
>
> It seems like it shouldn't be possible to use the absence of a string
> as an array key. Is it supposed to work that way? I'm using 8.0.1 on
> Windows.

Works that way on Ubuntu 14.04 and 16.04 as well. and AFAIK at least as 
far back as v6.7.


Not sure if it's a bug or a feature we just need to be very careful 
about, but you and I seem to be the only two people who've ever noticed 
that.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
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