KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Modifying shared objects vs shared collections
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: April 21, 2025

Shared objects and shared collections are both useful for handling grouped data that needs to be shared between processes. They are both created by their respective commands, “New shared object” and “New shared collection”, but there is a slight difference when modifying a shared object versus a shared collection. Generally, when modifying a shared object, the “Use..End use” syntax is required. For example:

$mySharedObj:=New shared object("foo"; 123)

Use ($mySharedObj)
  $mySharedObj.foo:=456
End use

When modifying a shared collection with a collection function, the “Use…End use” structure does not need to be explicitly written. For instance:

$mySharedColl:=New shared collection("bar"; "baz")
$mySharedColl.unshift("foo")

This is because collection functions already apply “Use…End use” internally. Keep this in mind when working with shared collections to save time writing code.