[fpc-pascal] Scoped enums and inferred types
Michael Van Canneyt
michael at freepascal.org
Wed Feb 21 08:57:18 CET 2018
On Wed, 21 Feb 2018, Ryan Joseph wrote:
>
>
>> On Feb 21, 2018, at 1:54 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
>>
>> So this is "as designed". If you want to be able to write A, don't use
>> scoped enums.
>
> I got the idea from Swift (one of the things it does right) and it’s
> really nice to be able say "this = .value” instead of
> NSSomeLongNameOfSomethingValueKey. It only works with assignments but it
> really cleans up code. The reasons I suggested it was because some of my
> function calls were just getting stupid long and annoying to type plus
> difficult to remember (that’s important for programmers!) so the compiler
> could certainly help here.
The job of the compiler is to create correct code.
Not to ensure you write readable code. Every feature that is introduced
offers more scope for abuse (generics jump to mind).
Only you can make sure your code is readable.
I think often the cure is often worse than the problem.
Simply don't use scoped enums if you want to type less.
Michael.
More information about the fpc-pascal
mailing list