4D Blog

Home Product Stricter class-based typing for objects

Stricter class-based typing for objects

July 16, 2025

Product

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.

Note: You can assign an object from one class to another class’s object, as long as one class inherits from the other. This supports both upcasting (assigning a subclass to a parent class variable) and downcasting (casting a parent class to a subclass, when appropriate). For example, since the Dog class inherits from the Animal class, you can safely write both:
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:

 blank

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.

blank

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.

Discuss

Tags 20 R10, 21, Database, Objects, ORDA

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Transform Static Documents into Actionable Knowledge with AIKit

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • AI
  • 4D Write Pro
  • Email, Microsoft 365, Gmail
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • 4D Qodly Pro
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy