Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3600484
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:30:03+00:00 2026-05-18T20:30:03+00:00

Parameter passing techniques: From what I can gather on these two techniques. Call By

  • 0

Parameter passing techniques:

From what I can gather on these two techniques.

Call By Reference:

The address location of the variable is being passed into the function, thus within the local scope of the function, any changes to the value of the local variable will change the value of the original variable, since they are pointing to the same place.

Call By Name:

The actual variable is being passed into the function. Any changes to the value of the variable inside the local scope of the function will also be reflected on the outside of the function.

It seems to me, these two parameter passing techniques accomplish the same thing? Both of them act on the original variables contents. Do I have my definitions wrong? Am I thinking about this in the wrong way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:30:04+00:00Added an answer on May 18, 2026 at 8:30 pm

    Call-by-name is slightly different than you describe. In pseudo code, imagine:

    function foo(index, value-increment)
        sum = 0
        loop index = 1 to 3
            sum = sum + value-increment
        return sum
    
    x = 3
    foo(x, 1 / x)
    

    If our foo call is by reference, the second argument, 1 / x, is evaluated only once giving us effectively: 1/3 + 1/3 + 1/3. It is a strict evaluation – each argument is fully evaluated before the function is applied.

    If we call by name, 1 / x is not strictly evaluated. Instead, it’s evaluated in the loop as it’s needed. Effectively, the loop becomes:

    loop x = 1 to 3
        sum = sum + 1 / x
    

    or 1/1 + 1/2 + 1/3.

    Take a look at thunks, though thunks don’t always mean call-by-name. Haskell has the idea of thunks but uses call-by-need where 1 / x wouldn’t be evaluated until it was needed but then would be evaluated only once (not to mention Haskell wouldn’t have a mutable loop variable).

    Other resources:

    • Call-by-name on the C2 wiki
    • Pass-by-name in CMPT 383 at Simon Fraser U.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Parameter passing techniques: From what I can gather on these two techniques. Call By
I want to call a url with passing some parameter and i want to
Parameter passing in Visual Studio . Note how __m128 types are passed. Does it
The below example is got from Jon Skeet's article, Parameter passing in C# .
I learnt the reference type parameter passing is just a copy of the reference.
Can't get my head around the parameter passing in Autofac, the following code doesn't
Can anyone help me out understanding the various parameter passing modes in Scheme? I
Possible Duplicate: Default value to a parameter while passing by reference in C++ Is
Which parameter passing method is used in Android? Pass by reference or Pass by
I am passing one parameter/object to the function RefValTest(object oIn) by the value but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.