comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com (Ted Dennison)
Subject: Re: array of operations
Date: 10 Sep 2002 19:17:29 -0700
Date: 2002-09-11T02:17:30+00:00	[thread overview]
Message-ID: <4519e058.0209101817.3c3cfb3b@posting.google.com> (raw)
In-Reply-To: alkt6b$t73$1@e3k.asi.ansaldo.it

"marco" <pippo@libero.it> wrote in message news:<alkt6b$t73$1@e3k.asi.ansaldo.it>...
> Do you know if there is some way of bulding up arrays of functions and/or
> procedures?...

Yes, there are ways.

However, the usual answer here to a "how do I do this very C-ish thing
in Ada?" question is "Why do you want to?"

So...Why do you want to? :-)

If it is to interface to a C routine that requires that exact type,
then OK, that's a legitimate reason.

However, if you just want an array that can be populated by clients
where the client gets to specify a behavior, there are other better
ways of doing it. For instance, have you considered using tagged types
and runtime polymorphisim? You make an array of pointers to some base
tagged type's "'Class", which has a primitive routine for you to call
(let's call it "Do_It"). Then each client can derive their own version
of that tagged type and override "Do_It" with their own operation.
This is much more powerful than meer function pointers, is generally
considered better OO design, and is better supported by the language.



      parent reply	other threads:[~2002-09-11  2:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-10 13:45 array of operations marco
2002-09-10 15:28 ` Mark Biggar
2002-09-10 17:09   ` Ehud Lamm
2002-09-11  7:43     ` Ole-Hjalmar Kristensen
2002-09-11 10:10       ` Ehud Lamm
2002-09-11 23:43         ` Randy Brukardt
2002-09-12  9:01           ` Ehud Lamm
2002-09-12 14:32             ` Mark Biggar
2002-09-12 16:15               ` John McCabe
2002-09-12 16:37                 ` David C. Hoos
2002-09-12 17:45                   ` John McCabe
2002-09-11  2:17 ` Ted Dennison [this message]
replies disabled

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