comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Type of the target of an assignment shall not be abstract
Date: Tue, 23 Feb 2010 16:19:55 -0500
Date: 2010-02-23T16:19:55-05:00	[thread overview]
Message-ID: <wccpr3vwsxw.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: op.u76m3fxfvwnd5a@garhos

"Hibou57 (Yannick Duch�ne)" <yannick_duchene@yahoo.fr> writes:

> Le Mon, 15 Feb 2010 18:05:09 +0100, Adam Beneschan <adam@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



  reply	other threads:[~2010-02-23 21:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-14 14:20 Type of the target of an assignment shall not be abstract Gautier write-only
2010-02-14 17:57 ` Dmitry A. Kazakov
2010-02-15 17:05 ` Adam Beneschan
2010-02-15 19:00   ` Hibou57 (Yannick Duchêne)
2010-02-23 21:19     ` Robert A Duff [this message]
2010-02-16  0:59   ` Adam Beneschan
2010-02-16 10:03     ` Gautier write-only
2010-02-16 12:14       ` Gautier write-only
2010-02-16 16:12       ` Adam Beneschan
2010-02-28 17:00 ` Gautier write-only
replies disabled

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