pass-by-name

Call by reference, value, and name

爷,独闯天下 提交于 2019-11-28 07:27:48
问题 I'm trying to understand the conceptual difference between call by reference, value, and name. So I have the following pseudocode: foo(a, b, c) { b =b++; a = a++; c = a + b*10 } X=1; Y=2; Z=3; foo(X, Y+2, Z); What's X, Y, and Z after the foo call if a, b, and c are all call by reference? if a, b, and c are call-by-value/result? if a, b, and c are call-by-name? Another scenario: X=1; Y=2; Z=3; foo(X, Y+2, X); I'm trying to get a head start on studying for an upcoming final and this seemed like

What is “pass-by-name” and how does it work exactly?

被刻印的时光 ゝ 提交于 2019-11-27 19:00:34
I've check wikipedia, and googled but I still can't wrap my mind around how pass-by-name works in ALGOL 60. I found a good explanation at Pass-By-Name Parameter Passing . Essentially, the body of a function is interpreted at call time after textually substituting the actual parameters into the function body. In this sense the evaluation method is similar to that of C preprocessor macros. By substituting the actual parameters into the function body, the function body can both read and write the given parameters. In this sense the evaluation method is similar to pass-by-reference. The difference

What is “pass-by-name” and how does it work exactly?

家住魔仙堡 提交于 2019-11-26 15:53:23
问题 I've checked Wikipedia and googled but I still can't wrap my mind around how pass-by-name works in ALGOL 60. 回答1: I found a good explanation at Pass-By-Name Parameter Passing. Essentially, the body of a function is interpreted at call time after textually substituting the actual parameters into the function body. In this sense the evaluation method is similar to that of C preprocessor macros. By substituting the actual parameters into the function body, the function body can both read and