Modify

Opened 10 years ago

Closed 10 years ago

#2574 closed Feature Request (Rejected)

"Switch...Case...EndSwitch"

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

Description

In the "Switch...Case...EndSwitch" construct, if a "case" check is true, then only the corresponding statements of that case are executed (Or also the following statements if the "ContinueCase" clause is used. However No further case checks are performed).
The case checks following the first "positive" check in the construct are ignored, and the program flow exits the "Switch" construct, branching to the end of the "Switch" body.
What I ask is if could be implemented a new statement/clause, that could modify (only on request) the flow behaviour of the switch connstruct, allowing all the check cases to be checked.
(for example, in the same way as is the default behaviour of the Switch construct in the C language, where all the "case" are checked (and eventually executed) if you do not explicitly use the "break" clause)
In some situations, this continuation may be desirable.

Attachments (0)

Change History (9)

comment:1 Changed 10 years ago by TicketCleanup

  • Version Other deleted

Automatic ticket cleanup.

comment:2 Changed 10 years ago by guinness

This is such a huge script breaking change and AutoIt != C.

comment:3 follow-up: Changed 10 years ago by jchd18

Maybe it could be possible to introduce a new NextCase statement without breaking anything.

comment:4 Changed 10 years ago by Melba23

I would reject this request as the functionality can essentially be reproduced by a sequence of If...EndIf structures. The whole point of Switch & Select structures is that they only allow for a single correct Case.

And I completely agree with guinness - although I would say:

AutoIt <> C

M23

comment:5 Changed 10 years ago by anonymous

That isn't possible in C. Also, C compilers try to build goto tables instead of checking every single case.

comment:6 in reply to: ↑ 3 ; follow-up: Changed 10 years ago by anonymous

Replying to jchd18:

Maybe it could be possible to introduce a new NextCase statement without breaking anything.

this is a right opinion,
could be an improvement addition (ameliorative)
a new "NextCase" statement (or also "ContinueCheck") that now is not implemented, could be the natural companion of the "ContinueCase" statement.
in effect as ContinueCase has his use, also "ContinueCheck" could have his use, (and without breaking anything). Just a new option that now is missing, that if not used, is all like before.
of course, As Melba23 says, "can essentially be reproduced by a sequence of If...EndIf structures", but this is also true for the "ContinueCase" statement (and could also be true for the same "Switch EndSwitch" construct). So why private ourself of new (and easily usable) opportunities given by available statements?
Moreover, if the C language has been provided with this opportunity in the construct, is because it can have his logic.
is true that "AutoIt <> C" but this do not means that must be lesser.

comment:7 in reply to: ↑ 6 Changed 10 years ago by anonymous

Replying to anonymous:

Moreover, if the C language has been provided with this opportunity in the construct, is because it can have his logic.

C does not allow more than one case for each value. Which opportunity are you talking about?

is true that "AutoIt <> C" but this do not means that must be lesser.

How does this make something possible, that was difficult to express before? How is this different from multiple if statements? Does it still correspond to the intended meaning of a switch statement, the meaning that every reader (including the person who wrote it) expects?
Is there any use case?

comment:8 Changed 10 years ago by anonymous

by reading the C documentation for the construct "switch endswitch" I figured, incorrectly, that omitting the "break" clause, could be performed successive checks on next "Case" statement".
But after a better reading, I have seen that if you do not use the term "break" then the subsequent instructions related to the next "Case" are executed anyway, also if there is no match with the next "Case" declaration.
Sorry for the misunderstanding.
Anyway, I think that the possibility to check all the "Case" cascading and executing the corresponding code only on match, could have his usefullness on the use of the construct (and furthermore it should have not contraindications at least)
Maybe, if not for the "Switch ... EndSwitch" construct,an ipothetical new "NextCase" statement it could be implemented for the "Select ... EndSelect" construct instead, allowing more than one of the Case statements to be checked "cascading" and only if the check is true then execute the corresponding code.
I have not a concrete case of use just now, but I "feel" that it could come handy before or after.

comment:9 Changed 10 years ago by Melba23

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

We do not add features because someone "feels" it might be useful. Come up with a concrete use case where sequenced If statements are too cumbersome and we might reopen the ticket.

M23

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

Action
as closed The ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.