KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Changes to Compiler Typing Practices
PRODUCT: 4D | VERSION: 20 R7 | PLATFORM: Mac & Win
Published On: November 25, 2024

With the changes and updates to the language, 4D 20 R7 intoduces some changes to the 4D compiler which impact the best practices that have been suggested for a while.

The 4D language has introduce various new ways to declare and type variables and parameters using the var and #DECLARE keywords.

In the past, the recomended best practices for using variables and parameters were to set the Database Settings Compiler to "All variables are typed" and explicitly type all of the uses of the variables and utilize the compiler's Generate Typing feature to create "Compiler_" methods. This would allow the code to be consistent with little possiblity for differences in interpretted mode and compiled mode.

4D 20 R7 introduces a new compiler feature called Direct Typing. This will be enabled by default for new projects and can be enabled in the Database Settings Compiler section. This feature will have the compiler behave as if "All variables are typed" is enabled requiring all variables to be typed. However, the feature no longer requires the "Compiler_" methods which can be removed from a database not moving back.

To prepare a database for this, it would be best to start with checking the compiler with "All variables are typed" enabled. This will return similar errors to having Direct Typing and allow ease of reverting and is available in the previous versions of 4D. If all errors have been addressed the database should be fine to have Direct Typing enabled, and have the "Compiler_" methods deleted after committing to keep Direct Typing enabled.