comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Variant record limitation - what's a better solution?
Date: Tue, 9 Jul 2013 08:11:05 -0700 (PDT)
Date: 2013-07-09T08:11:05-07:00	[thread overview]
Message-ID: <e6bc0a74-c905-4d89-ae0c-d3d5172ab318@googlegroups.com> (raw)
In-Reply-To: <krgt9r$2hu$1@news.albasani.net>

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 functions or entities, but I'm happy that it can't. Overriding the specific actions 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 based 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, which Ada accomplishes with tagged types and other languages with inherited classes or whatever.)  

In Ada (and other languages I know that have overloading), overloading is only supported where the compiler can determine, *at* *compile* *time*, which 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 distinguishes between whether you have a Lorry_Type with a Small load, or a Lorry_Type 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

  reply	other threads:[~2013-07-09 15:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-03  7:52 Variant record limitation - what's a better solution? Peter Brooks
2013-07-03  8:11 ` Georg Bauhaus
2013-07-03  9:39   ` Peter Brooks
2013-07-03 16:23 ` Jeffrey Carter
2013-07-03 18:35 ` Shark8
2013-07-03 19:26 ` Adam Beneschan
2013-07-09 11:48   ` Peter Brooks
2013-07-09 15:11     ` Adam Beneschan [this message]
2013-07-10  1:11       ` Peter Brooks
2013-07-03 20:55 ` Per Sandberg
2013-07-09  6:38 ` Peter Brooks
2013-07-09  7:49   ` Simon Wright
2013-07-09  8:22   ` Georg Bauhaus
2013-07-09 14:12   ` Eryndlia Mavourneen
replies disabled

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