Created
May 7, 2017 18:20
-
-
Save kmizu/4164df4fa6aaf0a35750eb66196bdf41 to your computer and use it in GitHub Desktop.
ある言語の引数評価戦略が、「値渡し」か「参照渡し」かを機械的に見分ける簡単な方法 ref: http://qiita.com/kmizu/items/20052fbaee1fe6b3e5ed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void swap(int x, int y) { | |
int tmp = x; | |
x = y; | |
y = tmp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def swap(x, y) | |
tmp = x | |
x = y | |
y = tmp | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int x = 1; | |
int y = 2; | |
swap(x, y); | |
printf("x = %d, y = %d\n", x, y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment