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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,174ec7dc941a1068 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Factory Pattern References: <1185387571.367570.163160@r34g2000hsd.googlegroups.com> In-Reply-To: <1185387571.367570.163160@r34g2000hsd.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1185411064 12.201.97.213 (Thu, 26 Jul 2007 00:51:04 GMT) NNTP-Posting-Date: Thu, 26 Jul 2007 00:51:04 GMT Organization: AT&T ASP.att.net Date: Thu, 26 Jul 2007 00:51:04 GMT Xref: g2news2.google.com comp.lang.ada:1189 Date: 2007-07-26T00:51:04+00:00 List-Id: shaunpatterson@gmail.com wrote: > > -- I would like it to work like this... > function createMessage (type : Integer) return Message_Class is > begin > case type is > when 0 => > return MessageInteger_Pkg.create (1234); > when others => > return MessageSomethingElse_Pkg.create > ("blah"); > end case > > end createMessage Obviously this won't work, since Messageinteger_Pkg.Create returns type Messageinteger, presumably a tagged record type, not Message_Class, an access type. I would think that an enumeration type would be better than Integer for selecting among a few choices. Using Integer probably reflects C/++ thinking. Like all well designed languages, Ada is not case sensitive. We tend to avoid camelCase, since the 1st thing people often do is run it through a reformatter that will convert it to the de facto Ada standard of Camelcase. Instead we separate words with underlines. Ada's features for programming by extension are somewhat different than C++'s, and you need to become familiar with the Ada concepts before trying something like this. Once you do, though, you may find you like Ada way better. You can have both static and dispatching calls to the same subprogram, for example. -- Jeff Carter "Sheriff murdered, crops burned, stores looted, people stampeded, and cattle raped." Blazing Saddles 35