comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: how to force the Small aspect of a new type derived from the generic formal type ?
Date: Thu, 25 Jan 2018 22:38:05 -0600
Date: 2018-01-25T22:38:05-06:00	[thread overview]
Message-ID: <p4ebbd$ab1$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: cb2eaa5d-f40d-4c35-8df4-b1e04d8d5a4b@googlegroups.com

"Mehdi Saada" <00120260a@gmail.com> wrote in message 
news:cb2eaa5d-f40d-4c35-8df4-b1e04d8d5a4b@googlegroups.com...
>> Either the teacher is asking for the impossible
>
> Actually the teacher isn't asking to do that: he asked at some point to 
> make it generic, at and at another, to force the Small. I assumed we could 
> do both.

You have to force the Small outside of the generic (on the actual type that 
is used to instantiate).

>>> you can't use most representation  aspects on a type derived from a 
>>> generic formal type.
>
> I understand. But with this statement:
>   type Modele is delta <>  with SMALL => MODELE'DELTA;
> I intend to pass a contract, so that only types whose Small is set the 
> same as the
> Delta will be accepted as valid parameters. I SUPPOSED it works like 
> this... I
> suppose now I was wrong ?

Most aspects can't be used on formal type because they would create an 
implicit contract that would require lots of rules to define. You in fact 
are trying to do exactly what we thought wasn't important enough to support.

In this case, you probably should just use an Assertion to make the check, 
that's not quite as good because it isn't a compile-time error (although you 
might get a warning from some compilers).

                                        Randy.



  reply	other threads:[~2018-01-26  4:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24 19:16 how to force the Small aspect of a new type derived from the generic formal type ? Mehdi Saada
2018-01-25  3:30 ` Randy Brukardt
2018-01-25 12:54   ` Mehdi Saada
2018-01-26  4:38     ` Randy Brukardt [this message]
2018-01-26 11:13     ` Alejandro R. Mosteo
2018-01-25 18:35   ` G. B.
2018-01-26  4:42     ` Randy Brukardt
replies disabled

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