From: Robert A Duff on
"Hibou57 (Yannick Duch�ne)" <yannick_duchene(a)yahoo.fr> writes:

> Le Mon, 15 Feb 2010 18:05:09 +0100, Adam Beneschan <adam(a)irvine.com> a
> �crit:
>>
>> This is indeed illegal, although offhand I'm not sure it should be.
> You cannot create an instance of an abstract type, initialized or not,
> so assignment is unlikely to be legal. Whatever it is of instantiation
> or assignment, this would not make no sense with an abstract type, as
> some method would not be defined. Well, to be honest, one alternative
> could have been to allow such a thing and simply disallow invocation of
> abstract methods (Borland Turbo Pascal did this), but then, what about
> if the object is passed as a class-wide parameter ? The method
> receiving the it as a class-wide parameter may access an abstract
> method. Allowing instantiation of abstracts and disallowing to pass it
> where class-wide is expected, would not have been clean.

I think it would make sense to allow creation of objects of an abstract
type, if you forbid conversion to class-wide (including the case you
mention, where there's an implicit conversion to class-wide when
passing a specific actual to a class-wide formal).

I guess assignments need to be forbidden, too, as somebody
mentioned in this thread -- in case there's an abstract Adjust.

The one case where I've wanted this feature is when I want
to use a function call as the ancestor part of an extension
aggregate, where the ancestor is abstract. I don't like
being forced to use default values in this case.

Alternatively, you could use a run-time check (any call to
an abstract subprogram raises an exception). Probably
a bad idea!

- Bob
From: Gautier write-only on
Just in case, here is a reduced example:
--
package Abstrax is
type Root is abstract tagged private;
type T1 is new Root with private;
procedure Reset(x: in out Root'Class);
private
type Root is abstract tagged record
i: Integer:= 11;
end record;
type T1 is new Root with record
j: Integer:= 22;
end record;
end;
--
package body Abstrax is
procedure Reset (x: in out Root'Class) is
y: T1;
begin
Root(x):= Root(y);
-- ^---- Wrong here !
end Reset;
end Abstrax;
--
Gautier