Adam Beneschan <adam@[EMAIL PROTECTED]
> writes:
> The disadvantage of this approach was given as this: "[P]redefined
> assignment and equality for discriminated Bounded_String do not have
> the desired behavior. Assignment makes sense when the maximum lengths
> of source and target are different, as long as the source's current
> length is no greater than the target's maximum length, yet predefined
> ":=" would raise Constraint_Error on the discriminant mismatch".
>
> The reason this doesn't make sense to me is, how does the generic
> definition solve the problem?
It doesn't, but it does cause the problem to be prevented statically,
rather than via an exception at run time.
As far as I know, there is no way to actually solve the problem in Ada
-- that is, allow all the assignments that make sense, and no others.
I must admit, that generic seems awfully heavy. Part of the rationale
(rationalization?) was that you can just pick some reasonable max
length, and instantiate the thing once, and use it all over your
program.
- Bob


|