comp.lang.ada
 help / color / mirror / Atom feed
From: "Alejandro R. Mosteo" <alejandro@mosteo.com>
Subject: Re: how to force the Small aspect of a new type derived from the generic formal type ?
Date: Fri, 26 Jan 2018 12:13:30 +0100
Date: 2018-01-26T12:13:30+01:00	[thread overview]
Message-ID: <p4f2gq$al0$1@dont-email.me> (raw)
In-Reply-To: <cb2eaa5d-f40d-4c35-8df4-b1e04d8d5a4b@googlegroups.com>

On 25/01/18 13:54, Mehdi Saada wrote:
>> 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 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 ?
> 

Unfortunately aspects+generics (or, in general <advanced 
feature>+generics) is one of the points where Ada orthogonality breaks 
down. In exchange you get sane generics, when compared to macro templates.

I'm saying this in a practical, user-experience sense, not as a language 
lawyer (which I'm not).

You can somewhat mitigate this with generic package formals, or with the 
"type T is new Base with private" kind of formals.

Even after many years of using Ada, I find the table in the following 
link a lifesaver from time to time:

https://en.wikibooks.org/wiki/Ada_Programming/Generics#Generic_formal_types

Incidentally, I wonder what good Ada cheatsheets are out there.

  parent reply	other threads:[~2018-01-26 11:13 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
2018-01-26 11:13     ` Alejandro R. Mosteo [this message]
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