[fpc-pascal] Extending an enumeration
JC Chu
jcchu at acm.org
Fri Dec 28 12:12:07 CET 2012
It is not possible to extend an enumeration type. If you are not
willing to use separate sets to hold common and extended elements, you
can use a generic (not parametric) set type, say SET OF 0..31, that
can hold all possible elements, and define the possible elements as
constants.
On Fri, Dec 28, 2012 at 6:42 PM, Mark Morgan Lloyd
<markMLl.fpc-pascal at telemetry.co.uk> wrote:
> Is it possible to extend an enumeration, while preserving strong type
> checking? In other words, given existing code like
>
> type TUpstreamServerCapabilitiesBase= (uscConnected, uscCanIssueGUID);
> TLocalServerCapabilitiesBase= (lscConnected, lscCanIssueGUID,
> lscIsFirebird);
>
> TUpstreamServerCapabilities= set of TUpstreamServerCapabilitiesBase;
> TLocalServerCapabilities= set of TLocalServerCapabilitiesBase;
>
> can the common parts of those enumerations- whether a connection was
> initially established and so on- be moved into a common declaration,
> preferably using "classical" Pascal so that I can store capabilities as a
> set?
>
> --
> Mark Morgan Lloyd
> markMLl .AT. telemetry.co .DOT. uk
>
> [Opinions above are the author's, not those of his employers or colleagues]
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
--
Best regards,
JC Chu
More information about the fpc-pascal
mailing list