[fpc-pascal] Extending an enumeration

Jetcheng Chu jcchu at acm.org
Sun Jul 18 18:53:08 CEST 2010


As far as I know, properties cannot be overridden.  However, you could
consider using subrange types, as the example below shows.

type
  Fruit = (Apple, Banana, Cherry, Orange, Pineapple);
  LimitedFruit = Apple..Cherry;

You can use the full enumeration as the property's type, and then
restrict its value using a custom property setter.

------ Original Message ------
Subject: [fpc-pascal] Extending an enumeration
Date: Sun, 18 Jul 2010 16:23:13 +0000
To: fpc-pascal at lists.freepascal.org
From: Mark Morgan Lloyd <markMLl.fpc-pascal at telemetry.co.uk>

> If I have a class with a property  Phase: TrrPhase  where TrrPhase is an
> enumeration such as (rrQuiescent, rrInitialised), is there an elegant
> way of extending the enumeration and overriding the property type so
> that a derived class can use the new values?
> 

-- 
Jetcheng Chu
http://people.rerouted.org/jcchu



More information about the fpc-pascal mailing list