- changed status to closed
IScriptObj.Destroyed should be a read-only property
Issue #38
closed
Since the IScriptObj.Destroyed
property setter (TScriptObjInstance.SetDestroyed
) completely ignores the value being set, the property should be read-only and the action of marking an object destroyed, with the side effects, performed by a regular method with no parameters.
For example:
IScriptObj = interface (IDataContext)
['{8D534D1E-4C6B-11D5-8DCB-0000216D9E86}']
function GetClassSym: TClassSymbol;
function GetExternalObject: TObject;
procedure SetExternalObject(value: TObject);
function GetDestroyed : Boolean;
procedure SetDestroyed;
property ClassSym : TClassSymbol read GetClassSym;
property ExternalObject : TObject read GetExternalObject write SetExternalObject;
property Destroyed : Boolean read GetDestroyed;
end;
Comments (2)
-
repo owner -
reporter Yes I'm aware of what it does. I'm just objecting to the use of a boolean property setter that ignores the value being set.
I.e. currently
ScriptObj.Destroyed := True;
and
ScriptObj.Destroyed := False;
does exactly the same. It would be better to use a method instead:
ScriptObj.SetDestroyed;
- Log in to comment
The Destroyed property of IScriptObj is not meant to necessarily destroy the underlying Delphi-side object(s), but to mark the script-side object as being destroyed, so that further references from the script will trigger an exception on the script-side.
The idea is that object life-cycle on the script-side and object life-cycle on the Delphi-side can be totally decoupled.