comp.lang.ada
 help / color / mirror / Atom feed
From: sommar@enea.se (Erland Sommarskog)
Subject: Re: Overloading of ":="
Date: 24 Dec 88 22:02:30 GMT	[thread overview]
Message-ID: <4189@enea.se> (raw)

Mats Weber (madmats@elma.epfl.ch) writes:
 >I said:
 >>   Generic
 >>      Type Data_type is limited private;
 >>      With procedure Assign(A : in out Data_type; B : in  Data_type);
 >>      With function ">"(A, B : Data_type) return boolean is <>;
 >>      With function "<"(A, B : Data_type) return boolean is <>;
 >>   Package Binary_trees is
 >>
 >>With an overloadable ":=" I could have declared the second parameter as
 >>
 >>      With procedure ":="(A : in out Data_type; B : in Data_type) is <>;
 >>
 >Instanciating and using this generic package with Standard.Integer (or any
 >type that does not have a default initial value) is ERRONEOUS because the
 >formal parameter A of Assign or ":=" is of mode 'in out', hence the
 >corresponding actual paramter must be an initialized variable.

This is of course erroneous no matter if we call the procedure Assign
or ":=". The interesting point is of course if the erroneousity
here is really crucial. As long as we don't actually read A, it
doesn't really matter. So for standard.integer there is no problem.
But for types with range constraints there could appear an unexpected
and unnecessary constraint_error. However, we can easily circumvent
this with a surpress pragma for our Assign procedure. 
  Now, WHY, is A of mode "in out" in the Assign procedure? If we had
"out" only, nothing "erroneous" could occur. And, any user who wanted
to store a limited type in a tree would get no help from us. (The 
Text type from Text_handler in the LRM is a perfect victim.) 
-- 
Erland Sommarskog
ENEA Data, Stockholm              This signature is not to be quoted.
sommar@enea.se

             reply	other threads:[~1988-12-24 22:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-12-24 22:02 Erland Sommarskog [this message]
1988-12-25 19:27 ` Overloading of ":=" William Thomas Wolfe,2847,
  -- strict thread matches above, loose matches on Subject: below --
1988-12-26 13:07 Erland Sommarskog
1988-12-20 13:05 Mats Weber
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox