comp.lang.ada
 help / color / mirror / Atom feed
* formal array types and default values
@ 2017-12-30 21:42 Mehdi Saada
  2017-12-30 22:20 ` Niklas Holsti
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Mehdi Saada @ 2017-12-30 21:42 UTC (permalink / raw)


I have several questions more or less related.
First: why aspect DEFAULT_COMPONENT_VALUE can apply only to components of scalar type ? It would be nice to be able to set a default value to an array type in a generic package, equal to a generic object parameter.

type T_Vect_Coef is array (T_Degre range <>) of ELEMENT;
gives that message:
main.adb:21:22: unconstrained subtype not allowed (need initialization)
main.adb:21:22: provide initial value or explicit array bounds

ELEMENT and T_DEGRE are generic and declared like that:
type ELEMENT is private;
type T_DEGRE is range <>;

Those two types are public. How can I give a default value, since DEFAULT_COMPONENT_VALUE doesn't apply to non scalar types.

In the private part,
the type
type T_Polynome (Degre : T_Degre := 0) is -- type mutant
    record
        COEF : T_Vect_Coef (0..Degre) := (others => NULL_ELEMENT);
    end record;
gives that warning: creation of "T_Polynome" object may raise Storage_Error. Why?


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-01-08 21:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-30 21:42 formal array types and default values Mehdi Saada
2017-12-30 22:20 ` Niklas Holsti
2017-12-30 23:59   ` Mehdi Saada
2018-01-03  0:52   ` Randy Brukardt
2018-01-03  8:33     ` Niklas Holsti
2018-01-03 20:53       ` Randy Brukardt
2018-01-06  0:10         ` Niklas Holsti
2018-01-08 21:12           ` Randy Brukardt
2017-12-31 12:34 ` Jeffrey R. Carter
2017-12-31 14:55   ` Mehdi Saada
2018-01-03 15:47 ` Mehdi Saada
2018-01-03 21:16   ` Randy Brukardt
2018-01-04 15:02 ` Mehdi Saada

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