Opened 10 years ago

Closed 10 years ago

#2633 closed Feature Request (Rejected)

more possibilities when assigning values to variables

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: variables, assignment Cc:


Just a few nice things that will probably be rejected:

$a = $b = $c = 0
; $a = 0
; $b = 0
; $c = 0


$a, $b, $c = 1, 2, 3
; $a = 1
; $b = 2
; $c = 3

3) (my favorite)

$a, $b = $b, $a
; $a = the old value of $b
; $b = the old value of $a

Attachments (0)

Change History (5)

comment:1 Changed 10 years ago by TicketCleanup

  • Version Other deleted

Automatic ticket cleanup.

comment:2 Changed 10 years ago by Mat

The first is completely impossible, because of the dual use of = in AutoIt. It's already used to imply $a = ($b = $c) which assigns $a to the result of the comparison. So no, 1st can be rejected straight away.

The 3rd is exactly the same as the 2nd, it's just a result of the order of operations, which if what you want in the 2nd is implemented correctly should always be the case.

So basically the ticket is can we assign a tuple of values to a tuple of variables.

Which is basically asking whether we can have tuples in AutoIt, because this is one of the features that's very common to languages that use tuples.

When I get round to it, I will open a new ticket requesting tuples, as it's been requested in the past, and then close this one.

comment:3 Changed 10 years ago by anonymous

Thank you Mat.

And maybe I can include 1) in my preprocessor, so it's not a big problem that it isn't possible.

comment:4 Changed 10 years ago by Mat

No, but it is ambiguous, and means you can't assign the result of a comparison to a variable.

For example in a preprocessor that expands variable names, the following could have two different meanings:

$a = $c = 4

If $c was a constant, and was expanded to 4, the result would look like:

$a = 4 = 4

Which is very different, and will assign True to $a.

Technically I'm sure it's possible to implement, but it's a bad idea and a bad design for a language.

The only reason it works in other languages is because the = operator returns the result of the assignment.

comment:5 Changed 10 years ago by Melba23

  • Resolution set to Rejected
  • Status changed from new to closed



Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.