Jump to content

Operator = not reflexive?


Recommended Posts

Hi.

The comparison operator = is not reflexive:

ConsoleWrite(Default = False)

ConsoleWrite(False = Default)

produces the output FalseTrue for me (AutoIT 3.2.10.0).

Is this the desired behavior?

There is some remark in the documentation about Default: "This keyword should not be used in computation expressions".

But actually I am not sure whether False = Default is a computational expression. If it is, why does the example for default show this idiom, if it should not be used?

Regards,

Samuel

Link to comment
Share on other sites

The comparision operator is == ,and = is and asignment operator.

Assignment operators are never reflexive,since you are copying data from right to the left,changing the order will change the result as expected.

The Default keyword must only be used in simple comparisions,and it can never be added,subtracted,modified,used as an variable,etc.

Link to comment
Share on other sites

I have to apologize, I meant "symmetric", not "reflexive" previous post.

The comparision operator is == ,and = is and asignment operator.

Assignment operators are never reflexive,since you are copying data from right to the left,changing the order will change the result as expected.

The Default keyword must only be used in simple comparisions,and it can never be added,subtracted,modified,used as an variable,etc.

No, the documentation says that both operators are comparison operators. The only difference lies in the case sensitivity when used with strings.

Strangely Default == False does produce the right result (False).

Apparently a bug, or what do you think?

Link to comment
Share on other sites

I have to apologize, I meant "symmetric", not "reflexive" previous post.

No, the documentation says that both operators are comparison operators. The only difference lies in the case sensitivity when used with strings.

Strangely Default == False does produce the right result (False).

Apparently a bug, or what do you think?

This is not a bug.

The behaviour you have observed is due to your misuse of the Default keyword

Debug

Keyword value use in function call.

$var = Default

Parameters

None.

Remarks

This keyword should not be used in computation expression. AutoIt will not detect such situation because it's too much performance penalty.

This demonstrated that = when used as comparison operator works correctly

$a = 1
$b = 0
ConsoleWrite($a = $B)
ConsoleWrite($b = $a)

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

The comparision operator is == ,and = is and asignment operator.

Uh.. not in AutoIt. From the help file:

= Assignment. e.g. $var = 5 (assigns the number 5 to $var)

...

= Tests if two values are equal (case insensitive if used with strings). e.g. If $var= 5 Then (true if $var equals 5)

== Tests if two values are equal (case sensitive if used with strings)

= is both assignment AND comparison:

$x = 2
$y = 3
ConsoleWrite(($x = $y) & @LF)
ConsoleWrite($x & @LF)
ConsoleWrite($y & @LF)oÝ÷ ØÚ-{MúÆ+,)eÙ§íz»ayø«²×(«Ê'
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...