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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.54.73 with SMTP id p9mr8162418qag.1.1373382665546; Tue, 09 Jul 2013 08:11:05 -0700 (PDT) X-Received: by 10.50.45.35 with SMTP id j3mr1390244igm.3.1373382665490; Tue, 09 Jul 2013 08:11:05 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!t19no871440qam.0!news-out.google.com!f7ni1652qai.0!nntp.google.com!t19no913298qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 9 Jul 2013 08:11:05 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: <0606a658-9816-4611-84dd-4f999bf6018e@googlegroups.com> <57dd4a15-f395-4938-89f2-027edadce24b@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Variant record limitation - what's a better solution? From: Adam Beneschan Injection-Date: Tue, 09 Jul 2013 15:11:05 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2616 Xref: news.eternal-september.org comp.lang.ada:16214 Date: 2013-07-09T08:11:05-07:00 List-Id: On Tuesday, July 9, 2013 4:48:11 AM UTC-7, Peter Brooks wrote: > I'm still not quite sure why a variant record can't have overloaded funct= ions or entities, but I'm happy that it can't. Overriding the specific acti= ons will work for me though. If the kind of overloading you're thinking of is one where a function looks= at the discriminant at runtime, and then decides which function to call ba= sed on the discriminant--it's not in the language because nobody put it in.= (What you're thinking of is closest to dispatching, or polymorphism, whic= h Ada accomplishes with tagged types and other languages with inherited cla= sses or whatever.) =20 In Ada (and other languages I know that have overloading), overloading is o= nly supported where the compiler can determine, *at* *compile* *time*, whic= h function or procedure will be called. It does this based on the types of= the parameters and (in Ada) on the return type. One thing to keep in mind= is that when you declare a variant record, the variant record is only one = *type*, not several types. Thus you can't have overloading that distinguis= hes between whether you have a Lorry_Type with a Small load, or a Lorry_Typ= e with a Medium load, etc. It's all just one type, a Lorry_Type. I hope this helps clear up some of the confusion. -- Adam