> 2018/10/02 4:48、Kirk Brooks via 4D_Tech <[email protected]>のメール:
>
> Just to be clear about what you're saying here - let's say I populate a
> large object, $bigObj, with some complex data. I might create a handle to a
> collection within it as you describe:
>
> $myCol:=$bigObj.a.b.c[2].someRef

in this example, it is not clear whether someRef is an object, collection, or a 
scaler value,
so let's focus on its parent c which is obviously a collection.

> $c:=$bigObj.a.b.c

$c would be a direct reference of the collection,
so $c[2] would point directly to the 3rd element of this collection which is a 
sub-sub property of $bigObj.

suppose we do something like

$o:=New object("foo";"bar")
$c.push($o)

we add $o to this collection ($bigObj.a.b.c) without touching its root object.

not only that, we can directly modify a property of this object even after it 
has been joined to another object or collection.

$o.foo:="not bar"

changes the value of $bigObj.a.b.c[3].foo

> This makes it easy to, say, iterate through each element. Beyond
> convenience are you saying this is more efficient than using the full dot
> notation?

it depends on how frequently you force 4D to evaluate dot notation.

for example.

> For each($e;$myCol)
>
> End for each

as opposed to

> For each($e;$myObj.a.b.c)
>
> End for each


is not that different, because $myObj.a.b.c is only evaluated once.

same with

> Use ($myObj.a.b.c)
>
> End use

but if you know you are going to use the same sub-sub-sub object or collection 
multiple times,
it makes no sense to have 4D re-evaluate the same static dot notation path over 
and over again.








**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to