|
From: <or...@vp...> - 2003-12-27 00:43:21
|
Michael C Urban wrote:
>>And about that { } braces inside the case: it is needed because
>>variables are declared inside the case, and they need to be kept in the
>>scope of the case statement, and that can only be achieved by creating a
>>block inside it.
>
>
> But the variables will go out of scope when the break or return statement
> is encountered won't they? Because the entire select block is enclosed in
> braces, so they variables will be local to the select block. Once the
> select block has exited, the variables should go out of scope shouldn't
> they?
>
> So given that, I don't see why the braces are necessary enclosing the
> case.
Because then the variables will be inside the CASE, not in the SWITCH,
and they only get allocated, if that specific CASE is selected, not
every time the program enters the SWITCH.
--
Greetings,
Balázs
|