[fpc-pascal] Dot syntax for types?

Sven Barth pascaldragon at googlemail.com
Sun Jan 14 09:27:38 CET 2018


Am 14.01.2018 03:42 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:

I remember I heard about a mode switch that requires "type groups” (what
are these called btw?) to use a . and be prefixed. For example:

type
        TGLType = (GL_FLOAT, GL_UNSIGNED_BYTE);


TGLType.GL_FLOAT would be the full name (note GL_FLOAT already is declared
so I want the type to be explicitly TGLType.GL_FLOAT in all cases). I need
to make some wrappers around OpenGL types and I thought this would be a
nice way to do it instead of declaring a bunch of constants with prefixes
but I just can’t remember how to handle that dot syntax (maybe it’s in the
trunk under development). Thanks.


Those types are called enumerations or enums for short, the variant that
requires a point are called scoped enums and the compiler directive you're
looking for is "{$scopedenums on}" and only needs to be used for declaring
the enum, not when using it. As the switch is a local one you can even mix
scoped and unscoped enum declarations in the same unit. The switch is
available at least since 3.0.0 though it isn't mentioned in the language
reference guide about enums (
https://freepascal.org/docs-html/current/ref/refsu4.html#x26-280003.1.1).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180114/de99d281/attachment.html>


More information about the fpc-pascal mailing list