Merging objects

Tripous uses object merging in many places where a caller supplies a small options object and the framework has to combine it with defaults. The central helpers are tp.MergeProps(), tp.MergePropsDeep(), and tp.MergePropsShallow().

A shallow merge copies property references. A deep merge copies primitive values as-is, clones dates and arrays, and recursively merges plain objects. The current implementation also checks tp.CanAssignProperty(), so a destination read-only property is not overwritten. Use tp.Assign() only when a simple enumerable-property copy is enough.

Simple assignment

tp.Assign() copies enumerable source properties to the target object. It does not deep-copy nested objects.

Shallow merge

tp.MergePropsShallow() copies the source property value directly. Nested objects remain shared references.

Deep merge

tp.MergePropsDeep() recursively merges plain objects and clones arrays and dates, so changing the source later does not affect the destination.

Writable properties

tp.CanAssignProperty() prevents merge code from writing to read-only destination properties. Missing properties are considered assignable.