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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dd8f3dccd1e7e410 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: Dynamic run-time Date: 2000/04/03 Message-ID: #1/1 X-Deja-AN: 606401547 Sender: bobduff@world.std.com (Robert A Duff) References: <8bvp21$ssv$1@nnrp1.deja.com> <38E3BAC4.FC400CA4@averstar.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 2000-04-03T00:00:00+00:00 List-Id: Tucker Taft writes: > xaplos@my-deja.com wrote: > > > > Does Ada provide an equivalent way of realizing the dynamic behavior > > that SmallTalk or Objective-C provides? For instance is there a datatype > > like Objective-C's id that allows variables and methods to be > > dynamically bind at run-time? > > Not really. Using tagged types you can do the kind of dynamic binding > that exists in C++ or Eiffel, but not the kind of "very dynamic" binding > that you can do in SmallTalk. The upside is that in Ada you will > never get a "message not understood." The downside is that you > can't read in from a terminal or equivalent the name of a function > or variable and somehow find and use the named entity. I once wrote a program that needed more dynamic dispatching than Ada's tagged types provide -- more along the lines of Smalltalk. So I wrote a generic package that kept track of tables of access-to-subprogram values. The tables were initialized at elaboration time, and after that everything was quite efficient. It wasn't that hard -- a couple or three hundred lines of generics, as I recall. Normally, however, I wouldn't do that. As Tucker pointed out, the built-in dispatching calls using Ada's tagged types provide a huge advantage in that you always dispatch to something that really does exist. - Bob