Adding finally to switch
Scott S. McCoy
tag at cpan.org
Mon Mar 31 21:52:17 PDT 2008
My thought on switch has always been: If you're using it as multiple if
statements, you're misusing it.
I always looked at switch as an opportunity to optimize, little more. I
never really thought the idea of switching on strings or similar was
really that sweet. If you ask me, such a construct is a fine idea, but
we should create a different construct for it (and a dispatch table
typically works better for that type of thing). That being said, switch
is not a tool you use every day. But that's fine, because when you
really *need* a real switch, its so incredibly handy it's unreal, and
you become grateful it's there and that it's so fast for what it does,
and that it lets you gracefully fall through and create "groups" of
behavior where you can't do that with other constructs as easily.
Cheers,
Scott S. McCoy
On Tue, 2008-04-01 at 03:56 +0000, Jesse Phillips wrote:
> I haven't given it much thought, but I figured I'd let some other people
> look at it too.
>
> Switch statements are nice, many people hate having to use break; all the
> time, but I don't and am not interest in the debate. What I think is
> missing from a switch statement is a finally section. Most of the time I
> don't have a use for the fall-through feature of switch, but I do have a
> use for doing one or more things that are the same in every case.
>
> As I haven't given it a lot of thought I will leave out some constraint
> ideas, and just see other peoples thoughts. I don't think it would ruin
> compatibility of any sort (backwards or C).
More information about the Digitalmars-d
mailing list