Re: Type safety, C++ and code generation



"Jeffrey R. Carter" <spam.not.jrcarter@xxxxxxxxxxxxxxxx> wrote in message
news:7ut4g.921904$x96.7750@xxxxxxxxxxxx
brian.b.mcguinness@xxxxxxxx wrote:

One solution to the problem would be to provide a new keyword for
defining types with no default operations. Only the operations you
explicitly defined would be available.

You mean like "limited private"?

Right. The problem with "limited private" is the loss of numeric literals
(and string literals in another use). Usually, it's been thought that the
solution is to somehow provide literals for private types. OTOH, no one has
ever made that work out well enough to get it into Ada, so perhaps a
radically different approach is needed.

But careful: the operators come with generic formal types, so there would
have to be restrictions on formals that are similar to whatever is defined
for types:

type Int is range 1 .. 10 without operators;

could not match

type An_Int is range <>;

since An_Int has the usual operators. (And for compatibility reasons, that
couldn't change.)

there would have to be new formal kinds like

type An_Int is range <> without operators;

to support matching for these types. (If you wanted to import the operators
defined for Int, you'd need to use a generic derived type.)

Randy.


.



Relevant Pages