[fpc-pascal] Scoped enums and inferred types

Michael Van Canneyt michael at freepascal.org
Wed Feb 21 10:34:24 CET 2018



On Wed, 21 Feb 2018, Ryan Joseph wrote:

>
>
>> On Feb 21, 2018, at 4:09 PM, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
>> 
>> I doubt that many would be using scopedenums for that.
>
> why not? Scoped enums did clean that up a little but still lots of extra typing during assignments and parameters.
>
> That compared to the previous is a still win though (less code is always a good thing).
>
> {$scopedenums on}
> type
> 	TTileSortingFlag = (	Static,
> 				Ramp,
> 				Ignore,
> 				Particle,
> 				Floor,
> 				Flat,
> 				Container,
> 				OnRamp,
> 				BufferStatic,
> 				BufferDynamic
> 				);
> {$scopedenums off}

And if you use
  type
        TTileSortingFlag = (    tsfStatic,
                                tsfRamp,
                                tsfIgnore,
                                tsfParticle,
  etc. );

You don't need scoped enums at all and the problem goes away.

You create a problem, and then you demand that the compiler introduces
tricks to solve the problem you created. Where is the logic in that ?

Don't create the problem to begin with, and we can all spend our time on
something more useful.

Michael.


More information about the fpc-pascal mailing list