From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c6150ba97747373e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-17 03:07:06 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: antonio_duran@hotmail.com (Antonio Duran) Newsgroups: comp.lang.ada Subject: Re: runtine instanciation Date: 17 Jun 2002 03:07:06 -0700 Organization: http://groups.google.com/ Message-ID: References: NNTP-Posting-Host: 192.101.1.126 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1024308426 5753 127.0.0.1 (17 Jun 2002 10:07:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 17 Jun 2002 10:07:06 GMT Xref: archiver1.google.com comp.lang.ada:26133 Date: 2002-06-17T10:07:06+00:00 List-Id: Dmitry A.Kazakov wrote in message news:... > Immanuel Scholz wrote: > > > Hello again, > > > > In Ada, can create a class at runtime? Like the getClass().forClass() in > > Java. > > > > As example create a variable from the type entered by the user at runtime. > > I am not sure what you want, but I suppose that Ada.Streams is what you > need. In short it allows you to create a class-wide object from some > external source (like user input) without a factory. Or better to say the > factory is distributed over the implementations of 'Input/'Read attributes. I'm not a Java expert I think that Java construct allows you to provide the name of a .class file (or a jar) that was not binded to your application at compile time, when you call that method, the virtual machine searches the CLASSPATH and if the .class (or .jar) is found they are loaded and binded to your application. This is not supported by any Ada language construct. That dynamic loading is a nice to have feature but has some problems. For example, if you have more than one version of that class there is the possibility of loading the wrong one. Retrieving a persistent object by using Ada.Streams allows you to create an object that was previously saved but the packages that contain the code for that class must be previously compiled and linked into your application. That is also true for C and C++. You can achive dynamic object loading by using object models like COM or CORBA (assuming the existence of support for these models as Ada libraries). For example, COM provides support for dynamic object loading (CreateObject) through what they call 'late binding'. Registering a component attach a class name (or identification) to a DLL, the DLL is brought to memory when CreateObject is invoked and by employing an introspection mechanism the application is able to know what are the properties, methods and events in the class and the infraestructure provides support for dynamic dispatching function calls (through RPC mechanisms) to the DLL functions. I think CORBA works, more or less, in a similar way. Antonio Duran