• When I call or invoke a function, think of it as creating a local table.

    当我调用一个函数时,想象一下它是在这里创建了一个局部表。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • When you call a function, what actually happens is that function gets its own chunk of memory that's identical in size to the data type that it expects.

    当你调用一个函数,实际上发生的是,函数得到了自己的内存块,相同的类型,是占有一样大小的内存的。

    哈佛公开课 - 计算机科学课程节选

  • That's a good thing. And instead of 17 million calls, I have 1800 calls.

    真好,我们只调用了1800次函数,而不是一开始的1百70万次。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • - Well, just a moment ago, we did have -- -- and this time I'll use some chalk here -- a moment ago, we did have a picture depicting what was going on when you call the function.

    好的,刚才,我们确实有-,这一次我将用一些粉笔-,刚才,我们有一张图描绘了当我们调用函数的时候,会发生什么事情。

    哈佛公开课 - 计算机科学课程节选

  • And one of the ways you can make a program crash, intentionally or not, is to essentially use up too much memory or call too many functions and what happens is, bam, one hits the other and bad things happen.

    其中一个方式能使你的程序崩溃掉,有意或无意的,它本质上使用了太多的内存,或者调用了太多的函数,所发生的,崩掉,一个冲突了另一个,然后发生了坏事情。

    哈佛公开课 - 计算机科学课程节选

  • You're calling functions, functions, functions, but you're allocating heap, heap, heap, heap memory for your words.

    我们一直调用函数函数函数,你一直为单词分配堆,堆,堆,堆。

    哈佛公开课 - 计算机科学课程节选

  • 8 Here, it gets a maximum value of 48 and 85 calls.

    这里它的最大值是8,函数调用了85次。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • But for now, think of this as just another way to write a function call.

    但是现在,把这当成是写函数,调用的另外一种方式就行了。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Well, if that function calls another function, you put another tray on, and so that new tray represents that function's chunk of memory.

    好的,如果那个函数调用另一个函数,你再放一个托盘在上面,新的托盘代表,那个函数的内存块。

    哈佛公开课 - 计算机科学课程节选

  • Well, if you want to call a function, it's like putting another tray on that stack of trays and that tray represents a chunk of memory that, that function can use.

    嗯,如果你想调用一个函数,这就像把一个托盘放到另一个托盘上,托盘代表一块,函数可以使用的内存。

    哈佛公开课 - 计算机科学课程节选

  • So let's think about lists. So if l is a list, l sort I can call something like s dot sort, l dot sort.

    所以让我们想想链表,所以如果l是一个,链表我可以调用像是s,sort的函数

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • When I ran it up here, with the old Fib, and we printed the result, and I ran it with Fib 1 down here.

    当我运行到这里,也就是老的Fib函数,我们打印这个结果,当我在下面调用Fib1时,也打印了结果。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And then I'll create this function, d1 this distribution d 1, which will, whenever I call it, give me a random, a uniformly selected value between minus and plus volatility.

    然后我会创建这个函数,这个概率分布,每次我调用这个函数的时候,他会给我返回一个随机的,按照均匀分布,从正负浮动值之间选择的值。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And it's taken me 25 calls.

    我一共调用了25次函数

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • increment Well, here, I'm calling my own function, increment.

    这里,我调用我自己的函数

    哈佛公开课 - 计算机科学课程节选

  • Because the algorithm I proposed is going to leverage this idea of recursion which recall was just a piece of jargon we tossed out at the last-- at the end of last week's lecture, last time's lecture recursion really in this context refers to the act of a function calling it's self.

    因为我提出的这种算法使用了,递归的思想,这是上周课程的最后,所提出的一个术语,上次的课程中,递归是指,函数的自我调用

    哈佛公开课 - 计算机科学课程节选

  • We've seen function calls before.

    我们之前看到过函数调用

    哈佛公开课 - 计算机科学课程节选

  • And again, a related problem that people run into is side-effects. You call a function and it returns a value, but maybe it, on purpose or on accident, modifies one of the actual parameters.

    另外,一个人们常碰到的相关问题,就是副作用,你调用一个函数它返回一个值,但是故意或者无意的,它可能会修改一个实参的值。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • But very soon will you find that if you're writing programs with lots and lots of functions, and some might call these, and these might call these, you can come up very soon with scenarios where you can not order them top to bottom, because everything is comingled, and there's a lot of cross talk among all of your functions.

    但是不久后你们会发现你们写的程序中,有很多很多的函数,有的函数调用这些函数,这些函数调用另外的函数,你不能用脚本,把它们从上到下排序,因为所有函数相互混合,在你的函数中也有很多交叉。

    哈佛公开课 - 计算机科学课程节选

  • In some sense, strictly speaking they shouldn't be necessary because the fact that my specification starts with an assumption, says, hey you, who might call square root make sure that the things you call me with obey the assumption.

    在某种意义上严格的来讲,它们不是必要的,因为我已经对假设做了声明,也就是说,如果你要调用我的,求平方根的函数,请确保你传递给我的,参数满足假设条件。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • GetInt You've been calling get string; you've been calling get in, maybe get float and a couple of others.

    你可以调用GetString,可以调用,可能是GetFloat,或者其他的函数

    哈佛公开课 - 计算机科学课程节选

  • And then I'll call fast Fib and it returns the result it has.

    然后我会调用快速Fib函数,然后它会返回它的结果。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Now because among its contents is the prototype for print F, that is why, very simply, I can call print F without having to declare its prototype myself.

    现在因为在它的内容中是printf的原型,这就是为什么我可以不声明printf函数的原型,而可以调用它。

    哈佛公开课 - 计算机科学课程节选

  • f Well, call toupper pass this lowercase F F to this function called toupper it's going to return capital F and so what do I assign to s2 bracket zero?

    调用toupper函数,传递这个小写,然后返回的是大写的,那么我对s2【0】赋值多少?

    哈佛公开课 - 计算机科学课程节选

  • Now if you call a function, swap like increment or cube or swap, or in this case, foo, those variables are the parameters to that function, end up getting stored next in memory.

    现在如果你调用一个函数,像increment或者cube或者,或者在这个例子里,foo,这些变量都是,函数的参数,在内存中存储。

    哈佛公开课 - 计算机科学课程节选

  • to do sqrt, or square root-- no, I'm going to square root use sqrt, that's the name I'm using here-- square root a hundred different places in some piece of code. Without function, I'd have to copy that piece of code everywhere.

    让我做一下准备,想象一下我要调用sqrt或者-,不,我会调用sqrt函数,这是我在这里用的名字,我得把这段代码到处复制。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Well, simply with the * notation at least on the way in when you declare the function called swap, you simply say this is not going to take an int and another int because that's useless.

    好的,简单说,当你声明一个函数调用swap函数时,使用*符号,你可以简单说,这不能使用一个int数和另外一个int数,因为那是无效的。

    哈佛公开课 - 计算机科学课程节选

  • And then I'll call fast max val passing at this extra argument of the memo.

    然后我会调用快速maxval函数,而它是基于这个额外变量memo的。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • The standard library, that first line of code, it's not strictly necessary but any time you use a function, a tool that someone else wrote that lives in that so called library, you do need that include line as we'll see.

    标准库函数--第一行代码,严格来说,不是每次都要写的,但是一旦你调用某个别人写,的函数,而这个函数又恰巧位于标准库里面,你就要像我们看到的这样,把它include进去。

    哈佛公开课 - 计算机科学课程节选

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定