Order of lookup

Top  Previous  Next

What is translated > Types > Order of lookup

The order by which symbols are looked up is different in Delphi and C#. Delphi tries to find a symbol in the last used unit at first and if it isn't there Delphi will continue with the previous used unit. If both used units contain the same symbol, but defined differently, this doesn't matter, because Delphi will take just the definition, that it finds first. In the following example MyType will be an integer:




uses lookupinunits2,  //  LType = TestRecord;

     lookupinunits1;  //  LType = Integer;




  MyType = LType;




procedure foo;


  i : integer;

  m : MyType;

  t : TestRecord;


  m := i;

//  m := t;   E2010 incompatibe types: 'Integer' and 'TestRecord'





In the translated C# code there are no type definitions, but m correctly becomes an integer, not a TestRecord.


public static void foo()


  int i = 0;

  int m = 0;

  TestRecord T = null;

  m = i;

  //  m := t;   E2010 incompatibe types: 'Integer' and 'TestRecord'





In C++ both definitions of LType would conflict. If LType would denote pointer types, then there would be an ambiguity. 



This page belongs to the Delphi2C# Documentation

Delphi2C# home  Content