You know I should expand on this a little bit:
On Sun, Apr 29, 2018 at 10:56 AM Kirk Brooks <[email protected]> wrote:
> Here are the equivalent statements for clearing $obj:
>
> CLEAR VARIABLE($obj)
> $obj:=Null
>
> The results are the same. A ‘cleared’ object variable is a Null object
> variable.
>
The results ARE the same but WHERE those results are may not be. In my
example $obj is defined as a single instance. But if $obj is defined as
part of a larger object it is a 'reference' to that part of the larger
object. I will change my example a little bit:
C_OBJECT($obj;$parentObj)
$parentObj:=New object("obj";New object) // create an object named 'obj'
in $parentObj
$obj:=$parentObj.obj // make $obj a reference to it
$ok:=(obj=Null) // $ok = false because it is defined
$obj.key:="value"// add a property named "key" with a value named "value"
$obj:=Null // ?
The expression '$obj.key:="value"' results in
$obj = {"key":"value"}
and
$parentObj = {"obj":{ "key":"value" }}
because $obj is a reference to the property in the parent object. So
changes to $obj actually change $parentObj.
Except for Null.
After executing $obj:=Null:
$obj = Null // true
$parentObj = {"obj": {"key":"value"}} // what?
Null "breaks" the reference linking between $obj and $parentObj. 'New
object', 'OB Copy', 'OB REMOVE' and 'CLEAR VARIABLE' have the same effect.
This is also true if I start in the $parentObj:
$parentObj.obj:=Null
// $obj (still) = {"key":"value"}
BTW - object properties (keys) are becoming more restrictive
<http://doc.4d.com/4Dv16R6/4D/16-R6/Using-object-notation-preview.300-3548251.en.html>.
They must begin with a letter, underscore or $. But the $ doesn't have any
particular significance in the name and can be used anywhere. Numbers are
OK just not for the first character. Dashes, spaces and such are not to be
used. As someone else said if you are still using spaces in names of
anything (except constants I suppose) you deserve what you get. Just stop
it.
--
Kirk Brooks
San Francisco, CA
=======================
*We go vote - they go home*
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************