德尔福的命名空间 [英] Namespaces in Delphi

查看:126
本文介绍了德尔福的命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用长单位文件名称(如
MyLib.MyUtils.pas )或者它只是一种单位名称前缀有什么实际的好处吗?

Are there any practical benefits in using long unit file names like MyLib.MyUtils.pas or it is just a kind of unit name prefix?

推荐答案

命名空间与所有标识符一样,是为了组织。

Namespaces, like all identifiers, are meant to organize.

所以使用它们只有您的项目得到更好的组织。
这个非常主观的事情(即使是最简单的命名约定也有战争),所以不可能真正回答。

So using them, only benefits if your project gets organized in a better way. This highly subjective matter (there have been 'wars' on even the most simple naming conventions!), so impossible to really answer.

以下是有关Delphi中命名空间如何工作的一些文档

请注意,true命名空间(其中多个通用DLL可以对同一个命名空间做出贡献;这是.NET世界中命名空间的功能)是不可能的Delphi:你可以去BPL的方式,但这不一样的'通用DLL'。这不是Delphi本身的限制,而是Windows中的本机DLL的工作方式。

Note that 'true' namespaces (where more than one generic DLL can contribute to the same namespace; this is how namespaces function in the .NET world) are not possible in Delphi: you could go the BPL way, but that is not the same as a 'generic DLL'. This is not a limitation of Delphi itself, but the way that native DLLs in Windows 'work'.

- jeroen

--jeroen

这篇关于德尔福的命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆