Delphi Programming Tutorial #57 - ScopedEnums Compiler Directive

preview_player
Показать описание
In this video Alister Christie looks at the $SCOPEDENUMS compiler directive when using enumerated types.

Alister Christie is a Delphi MVP (Most Valued Professional), Consultant, Developer, Trainer, Presenter, and Author. He has presented at ADUG (Australasian Delphi Users Group) Symposia and Code Rage Conferences for many years. Alister holds a degree in Mathematics and Computer Science from Victoria University, Wellington. He lives near Wellington, New Zealand.

On this YouTube Channel, Alister has created many hours of video tutorials to help you learn Delphi Programming in efficient and effective ways. Using his lessons, you will programme faster and better, skills applicable for beginners through to experts wanting to expand their programming and coding proficiency.

Video topics by Alister Christie include VCL (Visual Component Library), FireMonkey, FireDAC, Cross-platform, Android, iOS (iPad or iPhone Operating System), Mac OS/X, Windows, IoT (Internet of Things), Algorithms, and more.

Рекомендации по теме
Комментарии
Автор

@delticsnz I think the point is more that things can go wrong in unusual ways, not that my contrived example is representative of how one should write code in the large. But yes I agree, in most instances Delphi typing will prevent such errors.

codegearguru
Автор

2nd half of the demo was a bit suspect imho - you are highly unlikely to save the ord() of an enum member directly. Even if you aren't saving the enum member *name* (which you should be doing, of course) you are in any event far more likely to save the Ord() of a variable of a specific enum type, and cast back to that same type when loading from storage. Since variables are typed, the scoping issue of one "foot" obscuring another is highly unlikely to occur in the way shown.

JolyonSmith
welcome to shbcf.ru