comp.lang.ada
 help / color / mirror / Atom feed
* How do I create an object instance from a tag?
@ 2003-02-17 20:25 Steve
  2003-02-18  8:29 ` Dmitry A. Kazakov
  2003-02-20 15:38 ` Julio Cano
  0 siblings, 2 replies; 10+ messages in thread
From: Steve @ 2003-02-17 20:25 UTC (permalink / raw)


I would like to create a function that returns a reference to a class wide
object based on the external name.  Something along the lines of:

function Create_Object( external_name : String ) return objAcc is
  returnTag : Ada.Tags.Tag;
begin
  returnTag := Ada.Tags.Internal_Tag( external_name );
  return ??? some function of returnTag ???
end Create_Object;

Can this be done?

I've perused the rationale and the RM and haven't run across anything.

Steve
(The Duck)





^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: How do I create an object instance from a tag?
@ 2003-02-19  9:39 Grein, Christoph
  2003-02-19 13:26 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 10+ messages in thread
From: Grein, Christoph @ 2003-02-19  9:39 UTC (permalink / raw)
  To: comp.lang.ada

Problem with this proposal is abstract types. There must not be objects of an 
abstract type.

So if myTag denotes an abstract type, the proposal is illegal. It should at 
least propagate Program_Error.

So there are good reasons why there is not yet a solution for this problem.

(A solution, together with some trivial other amendments, could be used to find 
the nearest common ancestor of two tagged objects. Currently there is no way to 
find it.)

> IMO, the following is more consistent:
> 
>    myTag : Tags.Tag := ...;
>    value   : data_type'class (myTag);
> 
> and for dispatching:
> 
>    myTag : Tags.Tag := ...;
>    value   : data_type'class (myTag) := Create_Value;
> 
> or fully dynamically (qualified expression):
> 
>    myTag : Tags.Tag := ...;
>    value   : data_type'class :=
>        data_type'class (myTag)'(Create_Value);



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-02-20 15:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-17 20:25 How do I create an object instance from a tag? Steve
2003-02-18  8:29 ` Dmitry A. Kazakov
2003-02-18 18:14   ` Randy Brukardt
2003-02-19  2:27     ` Steve
2003-02-19  9:18       ` Dmitry A. Kazakov
2003-02-20 15:38 ` Julio Cano
  -- strict thread matches above, loose matches on Subject: below --
2003-02-19  9:39 Grein, Christoph
2003-02-19 13:26 ` Dmitry A. Kazakov
2003-02-19 18:36   ` Randy Brukardt
2003-02-20  9:15     ` Dmitry A. Kazakov

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