“图书馆"的确切含义飞镖中的关键字 [英] exact meaning of "library" keyword in dart

查看:41
本文介绍了“图书馆"的确切含义飞镖中的关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道此关键字应在某些自定义库中使用,但是当我放下它时,什么也没发生(至少我什么都没注意到),进口仍然运作良好,私人成员仍然是私人.

I know that this keyword should be used in some custom library, but when I dropped it, nothing happened (at least I didn't notice anything), imports still worked fine, private members remained private.

有人可以解释Dart中的库"关键字做什么吗?

Could somebody explain what "library" keyword in Dart do?

推荐答案

更新2018-03-05

有一阵子,一部分接受一个URI,这将 library 的需求减少到了少数情况.

For a while now, part of accepts a URI, which reduces the need of library to a few edge cases.

更新2015-11-27

在最近的更改中,两个导入的无名库不再发出警告.计划是使库声明完全可选.

With a recent change, two imported nameless libraries don't produce a warning anymore. The plan is to make the library declaration entirely optional.

库声明是可选的.如果省略,则库名默认为"" .
在某些情况下( pub build ),如果两个库的名称相同,则会出现错误,因此,通常的做法是设置正确的库名称.

The library declaration is optional. If it is omitted the library name defaults to "".
There are some situations (pub build) where you get an error if two libraries have the same name, so it's usually good practice to set proper library names.

在一个包含一个库的简单命令行应用中,通常可以省略库声明.

In a simple command line app consisting of one library it's usually fine to omit the library declaration.

来自 Dart语言规范

一个隐式命名的库的名称为空字符串.

An implicitly named library has the empty string as its name.

使用库的名称将其绑定到单独编译的部分库(称为零件)的一部分,可用于打印,以及更多通常,反射.该名称可能与其他语言有关进化.

The name of a library is used to tie it to separately compiled parts of the library (called parts) and can be used for printing and, more generally, reflection. The name may be relevant for further language evolution.

打算广泛使用的图书馆应避免名称冲突.Dart的酒吧包裹管理系统提供了一种执行机制所以.有效保证每个发布包的名称都是唯一的强制使用全局名称空间.

Libraries intended for widespread use should avoid name collisions. Dart's pub package management system provides a mechanism for doing so. Each pub package is guaranteed a unique name, effectively enforcing a global namespace.

这篇关于“图书馆"的确切含义飞镖中的关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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