dwsUnit: function returning interface

Issue #6 new
Anders Melander created an issue

In a TdwsUnit, it is possible to declare a function returning an interface. However it is currently not possible to actually implement this function.

I propose that this be made possible.

###Delphi side, dwsUnit declarations###

type
  IMyMessage = interface
    procedure Show;
  end;

type
  TMyMessage = class(IMyMessage)
  protected
    procedure Show;
  end;

function ShowMyMessage: IMyMessage;

###Delphi side, dwsUnit implementation, OnEval pseudo code###

procedure TMyMessage.Show;
begin
  ShowMessage('Hello world');
end;

function ShowMyMessage: IMyMessage;
begin
  // There's currently no way to return an interface:
  Result := new TMyMessage;
end;

###Script (example of use)###

begin
  var MyMessage = ShowMyMessage;
  MyMessage.Show;
end;

Comments (1)

  1. Log in to comment