Smart pascal source code
type
TBase = class
end;
type
TChild = class(TBase)
end;
var cond: Boolean;
var base := new TBase;
var child := new TChild;
WriteLn((if cond then TBase else TChild).ClassName);
WriteLn((if cond then base else child).ClassName);
WriteLn(if cond then 1.5 else 2);
WriteLn((if cond then TChild else TBase).ClassName);
WriteLn((if cond then child else base).ClassName);
WriteLn(if cond then 2 else 1.5);
cond := not cond;
WriteLn((if cond then TBase else TChild).ClassName);
WriteLn((if cond then base else child).ClassName);
WriteLn(if cond then 1.5 else 2);
WriteLn((if cond then TChild else TBase).ClassName);
WriteLn((if cond then child else base).ClassName);
WriteLn(if cond then 2 else 1.5);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
TChild
TChild
2
TBase
TBase
1.5
TBase
TBase
1.5
TChild
TChild
2
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var TBase = {
$ClassName:"TBase",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
}
,Destroy:TObject.Destroy
};
var TChild = {
$ClassName:"TChild",$Parent:TBase
,$Init:function ($) {
TBase.$Init($);
}
,Destroy:TObject.Destroy
};
var cond = false;
var base = null,
child = null;
/* <<< main JS >>> */
base = TObject.Create($New(TBase));
child = TObject.Create($New(TChild));
WriteLn(ClassName$1((cond)?TBase:TChild));
WriteLn(ClassName$1($ToClassType(((cond)?base:child))));
WriteLn(((cond)?1.5:2));
WriteLn(ClassName$1((cond)?TChild:TBase));
WriteLn(ClassName$1($ToClassType(((cond)?child:base))));
WriteLn(((cond)?2:1.5));
cond = !cond;
WriteLn(ClassName$1((cond)?TBase:TChild));
WriteLn(ClassName$1($ToClassType(((cond)?base:child))));
WriteLn(((cond)?1.5:2));
WriteLn(ClassName$1((cond)?TChild:TBase));
WriteLn(ClassName$1($ToClassType(((cond)?child:base))));
WriteLn(((cond)?2:1.5));