czardas Posted July 30, 2014 Share Posted July 30, 2014 (edited) It was done because people were abusing the fact that Default evaluated to -1. Passing Default to GUI controls, and created functions that took a numeric parameter and checking for -1 rather than explicitly checking for Default. Or the other way around and checking for Default but the user passing -1. Any evaluation of a number to try and guess if it is Default is wrong. Apart from triggering a fatal error, the only sensible number we can assign is 0. Not because it is more likely to be significant (it's not, -1 is more abnormal) but because it is more likely to be confused with an actual 0. That makes it more likely that the only sensible use of Default is to indicate one thing, the Default keyword. The correct use of testing for Default is: If $something = Default This will never fail because the user passed a number instead. I appreciate you taking time to explain this Jon. I didn't mean to come across as being critical. I understand your decision better now. I really just wanted to understand it to avoid making mistakes in my own design choices. Thanks. Edited July 30, 2014 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted July 30, 2014 Share Posted July 30, 2014 (edited) What if Default gives the optional params of a function their optional value? You may wish to assign a default optional value using a function call. That function could be anything (based on conditions), and it may complicate things too much - both to implement and for beginners to work with. I would say it is currently very flexible, even if it is slightly verbose. Edited July 30, 2014 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jchd Posted July 30, 2014 Share Posted July 30, 2014 eukalyptus, I've proposed that several times but received little interest and even rebutal. I can't get why Default shouldn't work this way. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
czardas Posted July 30, 2014 Share Posted July 30, 2014 (edited) But could it be made to work flexibly like this? : Func ConditionalDefault($vDefault = 0xFFFFFFFF) Local $iCondition = Random(0, 1, 1) Switch $iCondition Case 0 If $vDefault = Default Then $vDefault = FalseCondition() Case 1 If $vDefault <> Default Then $vDefault = TrueCondition() EndSwitch ; some code EndFunc ;==> ConditionalDefault Edited July 30, 2014 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 31, 2014 Share Posted July 31, 2014 (edited) If $a <> $a Then ; $a Must be null And no, I'm not making that up. $a could also be NaN or ±Infinity. Floating point non-numbers don't equal themselves either. Edited July 31, 2014 by Richard Robertson Link to comment Share on other sites More sharing options...
jchd Posted July 31, 2014 Share Posted July 31, 2014 (edited) Correct! That's why SQL IsNull (and IsNotNull) is useful. Edited July 31, 2014 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Mat Posted July 31, 2014 Share Posted July 31, 2014 $a could also be NaN or ±Infinity. Floating point non-numbers don't equal themselves either. Infinity can be compared without issue. You are right about NaN though. In reality, why you'd have a situation where you weren't sure if a variable was Null or NaN I don't know. AutoIt Project Listing Link to comment Share on other sites More sharing options...
jchd Posted July 31, 2014 Share Posted July 31, 2014 Indeed I didn't check +/- Inf. Maybe that depends on some flag setting in the FP unit but I won't check further. Anyway If $x = Null works everytime and is both clearer and simpler than If IsKeyword($x) = 2. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 3, 2014 Share Posted August 3, 2014 Yeah, I'm used to checking equality with null from other languages. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now