unit Myc.Lazy; interface uses System.SysUtils, Myc.Signals; type IMycLazy = interface {$REGION 'property access'} function GetChanged: IMycState; {$ENDREGION} function Pop( out Res: T ): Boolean; property Changed: IMycState read GetChanged; end; TLazy = record private FLazy: IMycLazy; function GetChanged: IMycState; inline; class var FNull: IMycLazy; class constructor CreateClass; public constructor Create( const ALazy: IMycLazy ); class function Construct( const Changing: IMycState; const Proc: TFunc ): IMycLazy; static; class operator Implicit( const A: IMycLazy ): TLazy; overload; class operator Implicit( const A: TLazy ): IMycLazy; overload; function Pop( out Res: T ): Boolean; inline; property Changed: IMycState read GetChanged; end; implementation uses Myc.Core.Lazy; constructor TLazy.Create( const ALazy: IMycLazy ); begin FLazy := ALazy; if not Assigned( FLazy ) then FLazy := FNull; end; class function TLazy.Construct( const Changing: IMycState; const Proc: TFunc ): IMycLazy; begin Result := TMycFuncLazy.Create( Changing, Proc ); end; class constructor TLazy.CreateClass; begin FNull := TMycNullLazy.Create; end; function TLazy.GetChanged: IMycState; begin Result := FLazy.Changed; end; function TLazy.Pop( out Res: T ): Boolean; begin Result := FLazy.Pop( Res ); end; class operator TLazy.Implicit( const A: IMycLazy ): TLazy; begin Result.Create( A ); end; class operator TLazy.Implicit( const A: TLazy ): IMycLazy; begin Result := A.FLazy; end; end.