Not a number is a number, problem

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Davidv
Posts: 77
Joined: Sun Apr 09, 2006 1:51 am
Location: Australia

Re: Not a number is a number, problem

Post by Davidv » Thu Mar 18, 2021 11:47 pm

dunbarx wrote:
Thu Mar 18, 2021 2:08 pm
David.

I almost forgot. How do you and I get different results for:

Code: Select all

"NAN" > "NAN"    ("true")
???

Craig
We don't get different results, Craig. :)

My text said, with emphases added, "If you do not get false, true, false, respectively then it is a bug>"

I don't get the required results and never have; neither do you nor anyone else. ergo, it is a bug.

David
Last edited by Davidv on Thu Mar 18, 2021 11:59 pm, edited 2 times in total.

Davidv
Posts: 77
Joined: Sun Apr 09, 2006 1:51 am
Location: Australia

Re: Not a number is a number, problem

Post by Davidv » Thu Mar 18, 2021 11:56 pm

The suggestion of concatenating a string with the value to ensure it is a string comparison is also way back in these pages. The proposal to use value() seems cleanest to me. Yet, that remains a workaround. INF can work with itself, so why not NAN? Why are we making excuses for the latter?

Reiterating, type coercion by the engine is not an issue provided it does so consistently on both sides of the comparison for the same datum. In the context of LC, alternative behaviour is a bug.

johnf923
Posts: 18
Joined: Tue Feb 23, 2021 8:20 pm

Re: Not a number is a number, problem

Post by johnf923 » Fri Mar 19, 2021 1:43 am

Davidv wrote:
Thu Mar 18, 2021 11:56 pm
Reiterating, type coercion by the engine is not an issue provided it does so consistently on both sides of the comparison for the same datum. In the context of LC, alternative behaviour is a bug.
With every respect, I think my previous post might have addressed this ...

Davidv
Posts: 77
Joined: Sun Apr 09, 2006 1:51 am
Location: Australia

Re: Not a number is a number, problem

Post by Davidv » Fri Mar 19, 2021 4:08 am

In a technical sense, John, yes, and I was very interested in your exploration and comment; indeed, in anything which may assist progress on an effective fix. I am also trying to keep the conceptual problem front and centre, that an apparent literal should compare correctly with itself.

New users, especially those not heavily versed in languages, have expectations of Livecode's behaviour (expectations unmet here I believe) so it helps to make any problems plain.

cheers
David

johnf923
Posts: 18
Joined: Tue Feb 23, 2021 8:20 pm

Re: Not a number is a number, problem

Post by johnf923 » Fri Mar 19, 2021 11:08 pm

Just a bit of a correction and clarification of my own post, if I may.

A few posts ago in this thread I said I thought there was a problem in the LC engine's source code with an uninitialized variable.

I now think that I was wrong there: I think the problem is in the logic of the function MCLogicCompareTo in exec-logic(dot)cpp. The function uses the results of the C++ comparison operators to generate its own results, implying that the design intention was to reproduce the C/C++ meanings of the operators in LiveCode. It fails to do that because of the way it's written: it needs to recognize NaN as a special case.

Not trying to argue a point; just correcting my earlier error for the record. And I now see that there's an existing bug report 22274 opened 2019-07-29 so this is already an open issue.

Davidv
Posts: 77
Joined: Sun Apr 09, 2006 1:51 am
Location: Australia

Re: Not a number is a number, problem

Post by Davidv » Fri Mar 19, 2021 11:37 pm

In that and other corresponding bug reports by him, Dar seems to conceive NAN only in a context of not-a-number, not as a string. LC's ability to treat NAN as a string is a live issue in typeless Livecode. I have taken some of the further elucidation here and added it to bug 23063.

David

johnf923
Posts: 18
Joined: Tue Feb 23, 2021 8:20 pm

Re: Not a number is a number, problem

Post by johnf923 » Sat Mar 20, 2021 1:18 am

Ok, well I've had my say and you're obviously not convinced, so at this point I'll bow out of your thread.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Not a number is a number, problem

Post by dunbarx » Sat Mar 20, 2021 3:15 am

David.
We don't get different results, Craig
I know. I was trying to make the point that, whether a bug, a ghostlike entity or psychotic gremlin, different machines are getting different results with a single identical self contained line of code.

This may be one definition of a "bug", in that "NAN" itself is so unstable that it is not accessible to two machines in the same way.

Craig

Davidv
Posts: 77
Joined: Sun Apr 09, 2006 1:51 am
Location: Australia

Re: Not a number is a number, problem

Post by Davidv » Sat Mar 20, 2021 3:28 am

That is a puzzling comment, John. Things before that are fine by me. I considered we were addressing different aspects, possibly even different problems depending on how you want to think about it. No matter.

David

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Not a number is a number, problem

Post by SparkOut » Sat Mar 20, 2021 5:43 pm

Yes, unless I am missing something, I think there are different issues here.

1) Whether the test of NaN against values of different types is producing correct results in the context of NaN as "not a number"

2) the original problem - why the string "NAN" is hijacked by the engine to be compared as "not a number" in certain situations, when clearly it has been defined as a string literal and should only be evaluated as a string literal.

3) Why there is nothing in the LiveCode lexicon which gives any explanation to any of this

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9251
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Not a number is a number, problem

Post by richmond62 » Sat Mar 20, 2021 5:49 pm

Why there is nothing in the LiveCode lexicon which gives any explanation to any of this
Oof.

The "LiveCode lexicon" [= Documentation ?] does not give explanations about quite a few things:

1. The Kind Answer: the folks at LiveCode centre assume (!) that users of LiveCode know a lot about computer
programming already so lots of information can be left out.

2. The Unkind answer: what quite a few Primary children have said to me when trying to do something at home.

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Not a number is a number, problem

Post by SparkOut » Sat Mar 20, 2021 9:43 pm

I'm not sure why you chose to make that post Richmond. I was restating the disparate issues that have been discussed in this thread, as there are apparently different perspectives.
As for the LiveCode documentation / dictionary / lexicon / whatever description of information might be provided by the kind folks at LiveCode centre, there are some gaps, anomalies, errors and omissions. I don't know, but I don't believe anyone at LiveCode centre would admit or suggest that any of those would be because they chose to assume that users didn't need to be told. Especially about an issue such as this.

Davidv
Posts: 77
Joined: Sun Apr 09, 2006 1:51 am
Location: Australia

Re: Not a number is a number, problem

Post by Davidv » Sat Mar 20, 2021 11:19 pm

SparkOut, eggerzackerley :). They are the three issues I have seen teased out here.

I might add to your second point a clause along the lines, "as LC manages for other special strings like INF".

David

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9251
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Not a number is a number, problem

Post by richmond62 » Sun Mar 21, 2021 10:22 am

I don't believe anyone at LiveCode centre would admit or suggest that any of those would be because they chose to assume that users didn't need to be told.
This is a universal problem that affects you, me and everyone else who has ever written an essay or a set of instructions:
the assumption that the reader(s) know something when they may not, versus the temptation to write instructions
that are so over-loaded with stuff for someone who knows exactly nothing that they are unuseable.

Just the other day someone had a problem with a Windows 10 installation and asked me to help.
Over the phone they mentioned, "You know XXX, YYY and ZZZ are not working." and were brought up short when
I told them I had NEVER used Windows 10 and did not understand what they were talking about, and were they
to let me see their machine I might manage to work out what was going on.

johnf923
Posts: 18
Joined: Tue Feb 23, 2021 8:20 pm

Re: Not a number is a number, problem

Post by johnf923 » Sun Mar 21, 2021 4:52 pm

A few posts ago I felt I needed to take a break from this discussion and looking back I realize I did so in a way that could at best be described as ungracious. I do apologize.

The fact is that I'm still working on this and would like to come back with a more detailed suggestion - but it's going to take more thought before it's ready. So please don't hold your collective breath but when I can I will try to explain what I mean.

Post Reply

Return to “Talking LiveCode”