new DIP47: Outlining member functions of aggregates

sclytrack sclytrack at fake.com
Mon Sep 9 02:29:44 PDT 2013


On Saturday, 7 September 2013 at 17:00:08 UTC, Walter Bright 
wrote:
> Outlining of member functions is the practice of placing the 
> declaration of a member function in the struct/class/union, and 
> placing the definition of it at global scope in the module or 
> even in another module.
>
> http://wiki.dlang.org/DIP47

---------------------------------------



unit Unit1;

{$mode objfpc}{$H+}

interface

uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, 
Dialogs, StdCtrls;

type

   { TForm1 }

   TForm1 = class(TForm)
     Button1: TButton;
     Memo1: TMemo;
     procedure Button1Click(Sender: TObject);
   private
     { private declarations }
   public
     { public declarations }
     procedure ChangeTitle(x:string);
     procedure ChangeOtherTitle(x: string);
   end;

var
   Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
   ChangeTitle('test');
end;

procedure TForm1.ChangeTitle(x: string);
begin
    Memo1.Lines.Add(x);
end;

procedure TForm1.ChangeOtherTitle(x: string);
begin
    Memo1.Lines.Add(x);
end;

end.




Here is how it looks like in Lazarus.
In the class definition you type the declaration.

   public
     { public declarations }
     procedure ChangeTitle(x:string);

Then you press "control shift c" this will create the empty 
implementation.
Use "control shift up" to cycle between the interface section and 
the implementation section.


There are two keywords "interface" and "implementation" to 
separate the two sections.

Honestly. There is not much typing going on.

If you go want to go the the next procedure in the implementation 
section it is faster to go "control shift up" back to the 
interface section. And then go to the next method and go back 
"control shift up" to the implentation section than to press the 
arrow down button until you are at the next method.


Lazarus does not accept changes in the name of the parameter.



More information about the Digitalmars-d mailing list