For this sprite only, means local, only this function, only this script can use this variable, make this variable for all sprites, meant it was global.
对于只为一种精灵,意思是局部的,只有这个函数中,这个脚本中才可以用这个变量,这个变量为全部精灵而创建,意思是这个变量是全局的。
Conceptually, it's put at the top of my chunk of RAM, -- below it, goes initialized and uninitialized data -- - this is a fancy way of saying global variables come next -- and below that, comes what's called the heap.
概念上,它放置在内存块的顶端,在下面,已初始化的和未初始化的数据-,这是一种指明紧随其后的全局变量的设想方式-,在后来,引入了一个叫做堆的东西。
in this global environment.
这里定义了一个全局变量。
Well, things can be fixed by a little trick called global variables.
好的,问题可以通过,一个叫做全局变量的东西来解决。
And the thing I wanted point out is, we've got this global variable number of calls. Which is there not because Fibonacci needs it but just for pedagogical reasons, so that we can keep track of how much work this thing is doing.
要指出的是我们已经,调用了几次这个全局变量,这不是因为斐波那契数列,需要调用它而只是,因为教学上的需要,以便我们可以知道,这个函数做了多少事情。
So, conceptually if you've ever wondered why you get access in all of your functions to global variables that's because they're not down here, they're at the very top of RAM and any function can access that RAM way up there, but for now the interesting player in the story is this thing called the heap.
所以,如果你想知道为什么全局变量能在,所有的函数中使用,那是因为它们不在这下面,而是在内存的顶端,那样任意函数都可以在内存中使用它们,现在,这里面一个有用的角色是,叫做堆的东西。
So I start this program by declaring as I did before a global variable X. It is global simply because it is not inside any of my functions.
在程序的开始,我声明,一个全局变量X,它是一个全局的,因为它不在任何一个函数里面。
When I'm talking to the interpreter, when I'm typing things in as I just did, to that Python environment, I'm getting what I'm going to call global bindings.
当我和解释器对话时,我会向我说的一样进行输入,输入到Python语言环境中,我会设置全局变量。
So variables you were introduced to in scratch, and there was this idea of global and local variables, but scratch called them something a little different.
在scratch中所介绍的变量,这里有一个全局变量和局部变量概念,但是scratch中有不同的叫法。
So pictorially, it's as though there's now some other part of the blackboard here, maybe way up here where I can put anything I want that's accessible to main, that's accessible to swap, that's accessible to increment or any other function I might implement because it is, in fact, global.
绘画般地,它是在这里黑板上的其他部分,可能在这里的上面,我在哪里可以放置这些东西,使它们可以被main函数使用,可以被swap函数使用,可以被increment函数使用,或者我所实现的其它函数,因为它实际上是一个全局变量。
应用推荐