-
Notifications
You must be signed in to change notification settings - Fork 631
Fix statement about evaluation strategy of methods #1425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Note that the cited blog post has syntactically wrong code examples, which does not inspire confidence... Can someone provide a more "official" view point (ruby core)? |
Maybe this answer of the mentioned stackoverflow discussion does contribute to the trustworthiness, because it quotes the O'Reilly book "The Ruby Programming Language". |
Great, that's exactly the kind of reference I had in mind :) Here the quote from Flanagan/Matsumoto as given on stackoverflow:
|
@@ -81,8 +81,8 @@ Unlike C, in Ruby,... | |||
* There’s no `#define`. Just use constants instead. | |||
* All variables live on the heap. Further, you don’t need to free them | |||
yourself—the garbage collector takes care of that. | |||
* Arguments to methods (i.e. functions) are passed by reference, not by | |||
value. | |||
* Arguments to methods (i.e. functions) are passed by value, whereas the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whereas -> where
@neumanrq wrote
I think you misunderstood the Wikipedia article. It clearly states that Ruby does not use "call by reference" but what they term "call by sharing" (i.e. call by value where the value is a reference); the paragraph you have cited only makes a statement about the used terminology:
I have no idea what the predominantly used terminology in the community is, though. |
Oh, yes, you're right, my bad. I fully agree to the wikipedia article argumentation on call-by-sharing and the article points that out correct. But the issue here remains: I still disagree to the statement
This statement was underlined by quoting ruby-lang documentation. That was the reason to make this proposal. I fixed the wording due to your suggestion. |
After investigating this question, I'm convinced that Ruby does not use call-by-reference, as stated in the section "To Ruby From C and C++" . It is using call-by-value as evaluation strategy for methods in canonical terminology.
See this blogpost or this stackoverflow discussion for deeper discussions on that question.
Obviously this information causes some confusion. For example, the wikipedia article on evaluation strategies referenced the ruby-lang documentation as a proof that Ruby does use call-by-reference:
That's why I'd suggest changing the information contained on the mentioned section.
Translations
I added the fix for German and English version, but since I'm not able to serve verified suggestions for the other languages, maybe the lang maintainers could assist?
Edit (stomar): relevant commits are bcb8d63 and e641ece.
Thanks!