Last week I had a good time at BorCon giving the CLR 2.0 pitch.  As promised here are my slides and demos.  Overall I thought the presentation when well.. I didn’t have any demo’s crash on me!   One of my favorite parts of the presentation was getting to show possible example syntax from a future version of Delphi… I love seeing how languages grow and change.

 

// ** hypothetical syntax from Danny Thorpe **

type

   List<T> = class

   private

      elements: array of T;

      FCount: Integer;

   public

      function getItems(index: Integer): T;

      procedure setItems(index: Integer; value: T);

      procedure Add(element: T);

      property Items[index: Integer]: T read getItems write setItems default;

      property Count: Integer read FCount;

   end;

procedure List<T>.Add(element: T);

begin

   if (FCount = elements.Length) then

      SetLength(elements, FCount * 2);

   elements[FCount] := element;

   Inc(FCount);

end;

function List<T>.getItems(index: Integer): T;

begin

  result := elements[index];

end;

procedure List<T>.setItems(index: Integer; value: T);

begin

  elements[index] := value;

end;

 

 

var

  intList: List<Integer>;

  i: Integer;

begin

  intList := List<Integer>.Create;

intList.Add(1);          // No boxing

intList.Add(2);          // No boxing

intList.Add(‘3’);        // Compile-time error

  i := intList[0];       // No cast required

end;

 

 

I’d love to hear feedback from folks that were at the event… what would you like to see covered differently.  Danny warned me that you’d likely pick apart subtle differences between the way Microsoft talks about the CLR and the way Borland talks about it… I’d love to hear those observations.