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 Path: g2news2.google.com!postnews.google.com!k33g2000yqa.googlegroups.com!not-for-mail From: xorque Newsgroups: comp.lang.ada Subject: Runtime type selection Date: Sun, 11 Oct 2009 09:41:54 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2c15c8a6-b555-4d08-8fe6-f77cb207e7a6@k33g2000yqa.googlegroups.com> NNTP-Posting-Host: 78.143.202.207 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1255279314 9083 127.0.0.1 (11 Oct 2009 16:41:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 11 Oct 2009 16:41:54 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k33g2000yqa.googlegroups.com; posting-host=78.143.202.207; posting-account=D9GNUgoAAAAmg7CCIh9FhKHNAJmHypsp User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.0.13) Gecko/2009081019 Firefox/3.0.13,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8667 Date: 2009-10-11T09:41:54-07:00 List-Id: Hello. I'd like to develop a program that processes a graph. The contents of the graph are a random selection of objects of different types (all elements may be of the same type or may all be different - assuming there are enough types defined). By 'type' in this case, I am referring to Ada types. The basic problem is that I want to create an object of a type picked at random, at runtime. I'm not entirely sure what my options are here. I could create a base tagged type and derive a set of types from that base, selecting at random. I could use variant records. It seems that in either case, I'd need to create an enumeration type with a 1:1 mapping between enumeration values and derived types. Both of these solutions seem a little unwieldly. They also seem like they'd end up making the program difficult to extend (I'd ideally just like to derive a new type and have it automatically available to be selected at random for the graph). Any ideas would be appreciated. I appreciate the problem is a little abstract...