Modify

Opened 12 years ago

Closed 12 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:

Description

Just a few nice things that will probably be rejected:
1)

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

2)

$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 by TicketCleanup, 12 years ago

Version: Other

Automatic ticket cleanup.

comment:2 by Matt Diesel, 12 years ago

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 by anonymous, 12 years ago

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 by Matt Diesel, 12 years ago

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 by Melba23, 12 years ago

Resolution: Rejected
Status: newclosed

Rejected.

M23

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.