Dmitry A. Kazakov schrieb:
> On Sun, 08 Jun 2008 17:19:11 -0400, Robert A Duff wrote:
>
>> Maciej Sobczak <see.my.homepage@[EMAIL PROTECTED]
> writes:
>>
>>> After all, with the possibility to initialize the new variable with
>>> arbitrarily complex expression (including function call), this is
>>> already the case and the whole declare-begin-end block is just
>>> reflecting some artificial separation.
>> I agree. I suppose it comes from Pascal, where declarations and
>> executable code are completely separated. It makes no sense in
>> Ada, where declarations are just as executable as statements.
>
> I disagree. I think it does make sense because it clearly defines the
scope
> of the declared variable.
Still, a somewhat *new* kind kind of handling exceptions in single
declarations looks interesting?
Given linear order of elaboration in declarative parts,
and thus the possibility of sequencing initialization
of local variables:
procedure P is
declare
X1: constant T; -- like Java final
begin
X1 := New_T(...); -- may raise CE
exception
when Constraint_Error =>
X1 := Fallback_T; -- better than Java final
end;
X2: D := New_D(X1, ...); -- safely refer to X1
begin
...
end P;


|