in addition to the distinction between shared and non-shared objects,
we need to be aware of the distinction between objects and non-objects.

the 4D language is different from script coding languages such as JS or PHP,
in that scalar types such as boolean, long, date, time are not objects.
they are native data types.

for instance, we know that

collection1:=collection2

is just a duplication of the object reference, not the object itself.

but long:=collection.longProperty

is a duplication of a native scalar value itself,
because numbers in 4D are not objects.

you can see the distinction in the documentation of "For each".

http://doc.4d.com/4Dv17/4D/17/For-eachEnd-for-each.300-3754311.en.html

(jump to keyword "scalar")

if you run a "For each" on a collection of objects,
the item you get in $1 is an object in the collection, which is a reference.
so updating it will directly update the object inside the collection.

but if you run a "For each" on a collection of scalar values,
the item you get in $1 is a copy of the value in the collection,
so updating it will not change the value inside the collection.

the ":=" operator is not inconstant.
what is really "inconsistent", is the nature of value types.

assigning an object or collection to another
is like assigning a DocRef (time), MenuRef (string), XMLRef (string), List 
(number) to another.
the operator never created a new file pointer, menu, XML node or list.

an object or collection property of a shared object is shared,
but a scalar property of a shared object is not,
because a scalar property is not an object,
which means it is not a reference,
which means there is no concept of sharing.

the language might be more consistent if 4D got rid of all native scalar types 
and treating everything as an object,
but there is a performance advantage (memory footprint and speed) in having 
scalar native types.

2018/10/21 21:04、Peter Bozek 
<peter.bo...@gmail.com<mailto:peter.bo...@gmail.com>>のメール:

it would be nice if assignment operator honored shared property as well and 
constructs like
collection:=selection.ID
would keep collection a shared one if it was before (and similar to assignment 
of collection created with .copy() .)




**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to