declare sth as a global
该结构表示把某个变量声明为全局变量,global 前可用 a 或 the。
You can declare the counter as a global if several functions need it.
如果多个函数都需要它,你可以把计数器声明为全局变量。
全局标识符
globals — plural of global
全局范围的标识符;通用的;全球的
globally scoped identifier
全局范围的标识符
A globally scoped identifier.
You can access this global from any function in the program.
你可以在程序中的任何函数里访问这个全局标识符。
用法提示:这里的 global 是名词,指在整个程序中都可访问的全局标识符。
The developer renamed the global to avoid a naming conflict.
开发人员重命名了那个全局标识符以避免命名冲突。
用法提示:global 作名词,表示一个具有全局作用域的标识符。
These globals are defined at the top of the script.
这些全局标识符定义在脚本的顶部。
用法提示:globals 是 global 的复数形式,指多个全局标识符。
该结构表示把某个变量声明为全局变量,global 前可用 a 或 the。
You can declare the counter as a global if several functions need it.
如果多个函数都需要它,你可以把计数器声明为全局变量。
a global 后用不定式说明这个全局变量的用途。
The program uses a global to share the settings across files.
程序用一个全局变量在各文件之间共享这些设置。
globals 用复数泛指全局变量,前面不加冠词。
Experienced programmers avoid globals in large projects.
有经验的程序员在大型项目中避免使用全局变量。
多用于 Python、JavaScript 等脚本语言的说明文字,指写在最外层作用域的变量;与编程口语里的 global 同义,但更强调作用域的层级位置,正式文档中比 global 更常见。
主要在 C 语言文献中使用,指在函数外部定义、具有外部链接的变量;含义比 global 更窄,带有链接性(linkage)这一专门含义,其他编程语言中一般不用。
grammar · medium
易错句子There are too much globals in this function.
正确表达There are too many globals in this function.
global 作名词指“全局标识符”时是可数名词,复数为 globals。修饰可数复数名词要用 many,不能用 much;汉语的“太多”不分可数不可数,因此容易误用 much。这里 globals 是可数复数,所以用 many。
grammar · medium
易错句子You should declare global before using it.
正确表达You should declare a global before using it.
global 是可数名词,单数形式前必须有冠词、指示词或所有格等限定词,不能光用名词裸形。汉语没有冠词,所以容易漏掉 a。这里泛指“一个全局标识符”,故用不定冠词 a。
grammar · medium
易错句子I added two global at the top of the file.
正确表达I added two globals at the top of the file.
汉语名词一般不因数量加词尾,而英语可数名词与大于一的数词连用时要加复数词尾 -s。two 后接可数名词,因此要用 globals,不能保留单数 global。
指作用域仅限于某个函数或代码块的标识符,与 global(全局作用域的标识符)相对;二者作用域范围不同,不能互换使用。
两者都表示编程中的作用范围:global 指整个程序任何位置都能访问的全局标识符,local 指只在定义它的函数或代码块内有效的局部标识符。强调覆盖整个程序时用 global,强调只限于某段代码时用 local。
globe 是名词,指地球或球状物体,与 global 拼写相近但词义无关。谈到地球、球体用 globe;指编程中作用域覆盖整个程序的标识符时用 global。
声明一个全局标识符
You need to declare a global before using it in another function.
在另一个函数中使用它之前,你需要先声明一个全局标识符。
定义一个全局标识符
The program defines a global at the top of the file.
程序在文件顶部定义了一个全局标识符。
访问一个全局标识符
The function can access a global from anywhere in the module.
该函数可以从模块中的任何位置访问一个全局标识符。
避免使用全局标识符
Experienced programmers often avoid globals to keep code maintainable.
有经验的程序员常常避免使用全局标识符,以保持代码可维护。
设置一个全局标识符
The configuration script sets a global for the API key.
配置脚本为 API 密钥设置了一个全局标识符。
glob(词根:球、球体) + -al(形容词后缀)
glob(词根:球、球体)
glob(词根:球、球体) + -ular(形容词后缀)
global(全球的) + -ization(名词后缀)
nation(词根:民族、国家) + -al(形容词后缀)
程序中可被命名的存储单元,常带作用域说明(如 global variable)。
名字可见的范围,global 正是描述某个名字处于最外层作用域。
组织名字的容器,global 名字往往定义在全局命名空间里。
程序中给变量、函数等起的名字,global 指的是其中作用域为全局的那一类。
值不可变的命名项,也可有全局与局部之分,与 global 常一同讨论。
地球村(因现代通讯与交通而紧密相连的世界)
Thanks to the internet, the whole world now feels like a global village.
多亏了互联网,如今整个世界就像一个地球村。
走向全球;拓展到国际市场
After years of success at home, the company decided to go global.
在国内取得成功多年后,这家公司决定走向全球。
放眼全球,立足本地
Our environmental campaign follows one rule: think global, act local.
我们的环保活动遵循一条原则:放眼全球,立足本地。
Dictionary facts from DICTIONARY_API_DEV, ECDICT, WIKTIONARY.