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,5394d9ca5f955366,start X-Google-Attributes: gid103376,public From: tmoran@bix.com (Tom Moran) Subject: pointers & OOP Date: 1999/05/01 Message-ID: <372b3b54.3547130@news.pacbell.net>#1/1 X-Deja-AN: 472937715 X-Complaints-To: abuse@pacbell.net X-Trace: typhoon-sf.snfc21.pbi.net 925580191 207.214.211.88 (Sat, 01 May 1999 10:36:31 PDT) Organization: SBC Internet Services NNTP-Posting-Date: Sat, 01 May 1999 10:36:31 PDT Newsgroups: comp.lang.ada Date: 1999-05-01T00:00:00+00:00 List-Id: In GNAT chat, John Robinson said: > It is difficult to do anything really useful with Ada 95 OOP features > without the use of pointers. Robert Dewar pointed to finalization actions as just one example of using OOP without pointers, and Matthew Heaney said: > ... it would be helpful to have a list of typical examples. so here's another: Sometimes, perhaps for task-safety or resource ownership reasons, the task that wants something done can't do it, but needs to ask a different service task to do the job. Rather than have a proliferation of 'entry's in the service task, one per type of job, make a single service entry that takes a "Job:in out Job_To_Do'Class" parameter and whose 'accept' merely calls a "Do_It(Job)" procedure. Any time some new type of job needs to be done, simply declare a child of Job_To_Do, with appropriate places in the record extension for parameters, and overide procedure Do_It(Job : in out Job_To_Do). Then a call to the service entry will dispatch to the desired Do_It routine so the service task will actually be the one executing the Do_It code. Essentially you are using Job_To_Do's dispatch table to pass a procedure pointer, and using the record extension to hold the parameters, but you are getting the compiler to build, and check, everything instead of relying on screwup-able explicit pointers.