| View previous topic :: View next topic |
| Should the words true and false become built-in constants? |
| I strongly agree. |
|
63% |
[ 7 ] |
| I moderately agree. |
|
18% |
[ 2 ] |
| I don't have a preference. |
|
9% |
[ 1 ] |
| I moderately disagree. |
|
0% |
[ 0 ] |
| I strongly disagree. |
|
9% |
[ 1 ] |
| I prefer something different. |
|
0% |
[ 0 ] |
|
| Total Votes : 11 |
|
| Author |
Message |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Jan 16, 2005 6:29 pm Post subject: Should true and false become built-in variables? |
|
|
Although AutoHotkey does not have a boolean data type (since all variables are stored as strings), having the words true and false as built-in constants might improve the readability of scripts. For example:
UseStandardMenu = Y
CaseSensitive =
Could be written instead as:
UseStandardMenu := true
CaseSensitive := false
(Note that the above must use the colon-equals operator to avoid percent signs around true/false)
Internally, true and false would be stored as 1 and 0, so it wouldn't be too much of a help when using the View menu's "List Variables". But it might be worth something.
The only drawback I see to adding them is the breaking of a few existing scripts that already use them as variable names. However, that is mitigated by the fact that the syntax checker would display an error when such scripts are loaded, making it easy to revise them.
Comments are welcome. Thanks for voting. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Sun Jan 16, 2005 6:54 pm Post subject: |
|
|
though i didn't very much like the language of 'I strongly disagree' but that's what i voted... well i think its not too much benefit compared to the points against it. _________________
 |
|
| Back to top |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Sun Jan 16, 2005 7:19 pm Post subject: |
|
|
| I think it can be a good thing, but not a necessity. For me it can be implemented but with a low priority. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Sun Jan 16, 2005 8:59 pm Post subject: |
|
|
| I think this is just short of necessary, since the most common use of variables is a simple on/off indicator. I think it's really cool to finally have a standard proposed for this, as boolean values should be separated from string values for both readability and practicality. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Mon Jan 17, 2005 1:52 am Post subject: |
|
|
| Great comments so far. More are welcome and appreciated. |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2402
|
Posted: Wed Jan 19, 2005 10:05 am Post subject: |
|
|
I think it may make code a bit easier to read.
True = 1 or -1
False = 0
? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Thu Jan 20, 2005 12:22 am Post subject: |
|
|
Currently, false is any variable that is empty or that contains 0 or 0.0. True is everything else, including 1, -1, or any other string.
However, when you assign true to a variable, or when an expression evaluates to true such as (1 > 0), the result will always be 1. This is done for consistency and also because it's traditional. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Jan 23, 2005 4:14 pm Post subject: |
|
|
Well, it's currently 4 to 1 in favor of the idea. Note that I do not vote in these polls, but if I were to vote in this one I would probably prefer it too.
If anyone has any more comments, feel free to post them. Also, I'll wait a few more days for more votes to come in.
Thanks. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Sun Jan 23, 2005 4:46 pm Post subject: |
|
|
though i don't plan to change my scripting ways due to this change, it seems fine if it doesn't break my existing scripts.  _________________
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Jan 23, 2005 4:58 pm Post subject: |
|
|
I think the only ones that would be broken are those that use the words true and false as variable names. Even those will not be broken in a bad way because the syntax checker will alert you the moment you launch such a script.
Still, breaking scripts is never a good thing. I feel it is only warranted when there is a significant benefit, which is what this poll is trying to find out. |
|
| Back to top |
|
 |
JSLover
Joined: 20 Dec 2004 Posts: 542 Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...
|
Posted: Sun Jan 23, 2005 5:19 pm Post subject: |
|
|
| Chris wrote: | | Could be written instead as: |
I don't care if they become aliases for true & false, but I don't want them to be the only way to determine true & false...so in your example, I'd still wanna be able to do the before...if you follow C & JavaScript's idea of true & false, I'll be at home...you CAN use true & false to check, but you can check other ways too. _________________
Home • Click image! • Blog |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Mon Jan 24, 2005 12:20 am Post subject: |
|
|
| Yes, the shorthand method such as "if Done" will still correctly check whether Done is true or false. You would also be able to write "if (Done = true)" if you prefer the long method. |
|
| Back to top |
|
 |
deguix
Joined: 26 Aug 2004 Posts: 72 Location: Everett - MA, USA
|
Posted: Mon Jan 24, 2005 1:51 am Post subject: |
|
|
(Hmmm... ignore this post because I forgot that you wanted to do like: var1 := true so I agree) _________________ Working now on:
NSIS Wiki (NSIS) |
|
| Back to top |
|
 |
hh
Joined: 05 Dec 2004 Posts: 13
|
Posted: Mon Jan 24, 2005 6:25 pm Post subject: |
|
|
it clearly improves code readability.
i can't really see any disadvantages - not any that matter to me anyways.
so, my vote was a clear yes. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Tue Jan 25, 2005 1:55 am Post subject: |
|
|
| True and False exist as built-in variables in the latest version. Thanks for all the votes and comments. |
|
| Back to top |
|
 |
|