With 4D 20 R10, object typing takes a major step forward, giving you more confidence and control in your code. Instead of simply checking if a value is an object, 4D now verifies that it’s an instance of a specific class. This unlocks smarter auto-completion, inline validation, and stricter compilation checks, helping you catch mistakes early and write clearer, more maintainable code.
The benefits don’t stop at variables and function results. This enhancement also applies to your data model: you can now assign a user-defined or native class (like the new 4D.Vector for your AI implementation) directly to an object field in the structure editor. 4D then understands the full shape of the object, from design time to runtime, enabling a type-safe and more reliable development experience.
HDI Typed Object field
Syntax & Compiler Checks for Object Field Attributes
4D now checks object type both in the following places:
-
Code editor, while typing
-
Compiler, during full syntax check
Incorrect object usage or typos will now appear as early warnings or errors, boosting reliability during refactoring and debugging.

var $animal:cs.Animal:=cs.Dog.new() // upcasting
// or
var $dog:cs.Dog:=cs.Animal.new() // downcasting
Define a Class for Object Fields
When you declare a field of type object in your data structure, the Structure editor inspector now includes a new Class input field. This lets you associate the field with a specific class, such as a business object or a native 4D class.
As an example, you can assign a type of 4D.Vector to a field named Vector:

Note: The Class field is only available when working in project mode.
Smarter Code Editor: Attribute Auto-completion
Thanks to the class association, the code editor now suggests attributes defined in the specified class when you write code involving the object field.
Conclusion
This update represents a major improvement in how object fields are treated within 4D. By supporting stricter typing with classes, 4D gives you a more robust, maintainable, and intelligent development experience from structure design all the way to runtime execution.
