comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Subtype or derived type?
Date: Mon, 9 Oct 2017 16:50:18 -0500
Date: 2017-10-09T16:50:18-05:00	[thread overview]
Message-ID: <orgquq$crb$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: orauq5$9tv$1@gioia.aioe.org

"Victor Porton" <porton@narod.ru> wrote in message 
news:orauq5$9tv$1@gioia.aioe.org...
...
> I have two variants in mind:
>
> 1.
>
> subtype Node_Type is Term_Type;
>
> 2.
>
> type Node_Type is new Term_Type;
>
> Please advise which of the two is better.

It depends on how you want to use the type/subtype, of course.

If you need overridding/overloading, then you probably want a new type (a 
derived type), so the compiler can differentiate. If you need to convert 
back and forth a lot, you probably want a subtype (so the conversions are 
implicit rather than explicit). And so on...

                            Randy.



      parent reply	other threads:[~2017-10-09 21:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-07 16:19 Subtype or derived type? Victor Porton
2017-10-07 16:23 ` Victor Porton
2017-10-07 16:24   ` Victor Porton
2017-10-09 21:50 ` Randy Brukardt [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