快过节了,首先祝福大家在新的一年里更进一步.
一般我做程序是把用到的单元文件名放在"实现"中,今天发现有的代码把他放到"接口"中,我也放上发现没出什么错误.
但是不明白二者的区别.

解决方案 »

  1.   

    我要是把数据模块放到"接口"中,能实现全局变量的存储吗?ado
      

  2.   

    什么是循环引用?a用了b,b用了c,c又用了a?
      

  3.   

    To compile a client module, the compiler needs to locate all units that the client depends on, directly or indirectly. Unless the source code for these units has changed, however, the compiler needs only their .dcu (Windows) or .dcu/.dpu (Linux) files, not their source (.pas) files.When changes are made in the interface section of a unit, other units that depend on it must be recompiled. But when changes are made only in the implementation or other sections of a unit, dependent units don't have to be recompiled. The compiler tracks these dependencies automatically and recompiles units only when necessary.
      

  4.   

    帮助文件对循环引用是这样描述的:When units reference each other directly or indirectly, the units are said to be mutually dependent. Mutual dependencies are allowed as long as there are no circular paths connecting the uses clause of one interface section to the uses clause of another. In other words, starting from the interface section of a unit, it must never be possible to return to that unit by following references through interface sections of other units. For a pattern of mutual dependencies to be valid, each circular reference path must lead through the uses clause of at least one implementation section.In the simplest case of two mutually dependent units, this means that the units cannot list each other in their interface uses clauses. So the following example leads to a compilation error:unit Unit1;
    interface
    uses Unit2;
    ...
    unit Unit2;
    interface
    uses Unit1;
    ...However, the two units can legally reference each other if one of the references is moved to the implementation section:unit Unit1;
    interface
    uses Unit2;
    ...
    unit Unit2;
    interface
    ...
    implementation
    uses Unit1;
    ...To reduce the chance of circular references, it's a good idea to list units in the implementation uses clause whenever possible. Only when identifiers from another unit are used in the interface section is it necessary to list that unit in the interface uses clause.其实,简单的说,大概地,可以这样理解,
    放在interface的,可以被其他的看见
    而放在implementation的,使这个单元私有的,其他单元不可见
    这个就类似于面向对象思想里面的public变量和private变量的区别。