Re: [fpc-pascal] Extending an enumeration

2012-12-28 Thread Mark Morgan Lloyd
Ludo Brands wrote: On 28/12/2012 12:59, Ludo Brands wrote: On 28/12/2012 12:48, Mark Morgan Lloyd wrote: Ludo Brands wrote: type TAllServerCapabilitiesBase=(uscConnected, uscCanIssueGUID,lscConnected, lscCanIssueGUID, lscIsFirebird); TUpstreamServerCapabilitiesBase= uscConnected .. usc

Re: [fpc-pascal] Extending an enumeration

2012-12-28 Thread JC Chu
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

Re: [fpc-pascal] Extending an enumeration

2012-12-28 Thread Ludo Brands
On 28/12/2012 12:59, Ludo Brands wrote: On 28/12/2012 12:48, Mark Morgan Lloyd wrote: Ludo Brands wrote: type TAllServerCapabilitiesBase=(uscConnected, uscCanIssueGUID,lscConnected, lscCanIssueGUID, lscIsFirebird); TUpstreamServerCapabilitiesBase= uscConnected .. uscCanIssueGUID; TLo

Re: [fpc-pascal] Extending an enumeration

2012-12-28 Thread Ludo Brands
On 28/12/2012 12:48, Mark Morgan Lloyd wrote: Ludo Brands wrote: type TAllServerCapabilitiesBase=(uscConnected, uscCanIssueGUID,lscConnected, lscCanIssueGUID, lscIsFirebird); TUpstreamServerCapabilitiesBase= uscConnected .. uscCanIssueGUID; TLocalServerCapabilitiesBase= lscConnected..

Re: [fpc-pascal] Extending an enumeration

2012-12-28 Thread Mark Morgan Lloyd
Ludo Brands wrote: On 28/12/2012 11:42, Mark Morgan Lloyd wrote: Is it possible to extend an enumeration, while preserving strong type checking? In other words, given existing code like typeTUpstreamServerCapabilitiesBase= (uscConnected, uscCanIssueGUID); TLocalServerCapabilitiesBa

Re: [fpc-pascal] Extending an enumeration

2012-12-28 Thread Mark Morgan Lloyd
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.

Re: [fpc-pascal] Extending an enumeration

2012-12-28 Thread Ludo Brands
On 28/12/2012 11:42, Mark Morgan Lloyd wrote: Is it possible to extend an enumeration, while preserving strong type checking? In other words, given existing code like typeTUpstreamServerCapabilitiesBase= (uscConnected, uscCanIssueGUID); TLocalServerCapabilitiesBase= (lscConnected, l

Re: [fpc-pascal] Extending an enumeration

2012-12-28 Thread JC Chu
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

[fpc-pascal] Extending an enumeration

2012-12-28 Thread Mark Morgan Lloyd
Is it possible to extend an enumeration, while preserving strong type checking? In other words, given existing code like typeTUpstreamServerCapabilitiesBase= (uscConnected, uscCanIssueGUID); TLocalServerCapabilitiesBase= (lscConnected, lscCanIssueGUID, lscIsFirebird); TUps

Re: [fpc-pascal] Extending an enumeration

2010-07-21 Thread Mark Morgan Lloyd
Thierry Coq wrote: On 18/07/2010 20:56, Mark Morgan Lloyd wrote: ... Yes, I was thinking that. However if the basic class was say a round-robin scheduler with phases rrQuiescent and rrInitialised and the descendant was say an HP comms protocol handler with additional phases hpReceivingPadding,

Re: [fpc-pascal] Extending an enumeration

2010-07-20 Thread Thierry Coq
On 18/07/2010 20:56, Mark Morgan Lloyd wrote: ... Yes, I was thinking that. However if the basic class was say a round-robin scheduler with phases rrQuiescent and rrInitialised and the descendant was say an HP comms protocol handler with additional phases hpReceivingPadding, hpReceivedSync and

Re: [fpc-pascal] Extending an enumeration

2010-07-18 Thread Jetcheng Chu
> Yes, I was thinking that. However if the basic class was say a > round-robin scheduler with phases rrQuiescent and rrInitialised and the > descendant was say an HP comms protocol handler with additional phases > hpReceivingPadding, hpReceivedSync and so on it would seem to be > questionable pract

Re: [fpc-pascal] Extending an enumeration

2010-07-18 Thread Mark Morgan Lloyd
Jetcheng Chu wrote: 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 typ

Re: [fpc-pascal] Extending an enumeration

2010-07-18 Thread Jetcheng Chu
trict its value using a custom property setter. -- Original Message -- Subject: [fpc-pascal] Extending an enumeration Date: Sun, 18 Jul 2010 16:23:13 + To: fpc-pascal@lists.freepascal.org From: Mark Morgan Lloyd > If I have a class with a property Phase: TrrPhase where TrrPha

[fpc-pascal] Extending an enumeration

2010-07-18 Thread Mark Morgan Lloyd
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? -- Mark Morgan Lloyd markMLl .AT. tel