[fpc-pascal] Extending an enumeration

JC Chu jcchu at acm.org
Fri Dec 28 13:58:24 CET 2012


If you do not allow clients of your unit to define new elements or
change the set values, and what you want to do is prevent, say,
accidentally adding an extended element to the set in the base class,
you can declare extended elements as class-local constants.  Otherwise
you will need to add checks in property setters.

On Fri, Dec 28, 2012 at 7:33 PM, Mark Morgan Lloyd
<markMLl.fpc-pascal at telemetry.co.uk> wrote:
> JC Chu wrote:
>>
>> 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.
>
>
> Yes, except that that loses type checking.
>
>
> --
> 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