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 7043827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:20:12+00:00 2026-05-28T02:20:12+00:00

In most programming languages, arguments passed to a function are evaluated before the function

  • 0

In most programming languages, arguments passed to a function are evaluated before the function uses them, that is, they are evaluated eagerly.

To me, it seems like it would make much more sense to evaluate the arguments only once the function uses them, that is, lazily. This makes more sense to me because it seems like it would have a performance benefit: why evaluate things that are never even needed?

Moreover, suppose you wanted to implement an if function that accepts a boolean, and an object to return if the boolean is true, and another object to return if the boolean is false:

object if(bool condition, object valueIfTrue, object valueIfFalse) {
  if(condition) return valueIfTrue;
  return valueIfFalse;
}

In a language that eagerly evaluates arguments, both objects are always evaluated even though the function will always only need one of them, which, at best, incurs a slight unecessary overhead, and, at worst, causes an infinite loop.

That said, since most programming languages use eager evaluation of function arguments, I assume there must be a reason why it’s usually done that way. Is there some big benefit of eager evaluation here that I’m overlooking, is it just because it was easier to implement languages that way, is it just tradition, or what?

  • 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-28T02:20:13+00:00Added an answer on May 28, 2026 at 2:20 am

    There are a couple reasons I’ve seen for eager evaluation, both of which are important:

    1. Eager evaluation means that side effects happen immediately and always. If you use lazy evaluation, you can’t rely on the side effects of something you’ve done previously to have taken effect.
    2. Lazy evaluation brings with it a certain amount of memory bloat. It generally takes much less memory to store the result of a calculation than it does to store the thunk that describes the calculation. This can lead to using too much memory (ie, time vs. memory tradeoffs) and, sometimes more importantly, a harder time figuring out the memory characteristics of the program/algorithm.

    Lazy evaluation can be a powerful tool, but it’s not without it’s costs. Purely functional languages tend to avoid problem #1 because they don’t have side effects (in general), but are still bitten by problem #2 at times. Languages that allow delayed evaluation (LISP macros are a form of this, though not the same as lazy evaluation) can have the best of both worlds, but at the cost of more effort on the programmer’s part.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems like in most mainstream programming languages, returning multiple values from a function
It seems that most new programming languages that have appeared in the last 20
I'm aware that most things in modern programming languages are at least partially based
I was wondering if anyone knew why some programming languages that I see most
That's pretty much it. Scoping in most OO programming languages resolves symbols fine without
I want to do something like in PHP, Python and most other programming languages:
In most programming languages I have used you can do something like (where s
I know that most programming languages are Turing complete, but I wonder whether a
It's common knowledge in most programming languages that the flow for working with files
I understand the concepts of \t and \n in most programming languages that have

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.