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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:27:57+00:00 2026-05-20T15:27:57+00:00

I’m a bit confused as to the term closure used within the Groovy documentation

  • 0

I’m a bit confused as to the term “closure” used within the Groovy documentation. According to the documentation, their definition of a closure seems more like an anonymous function or lambda.

I understand that languages that support first class functions, typically allow closures to be formed. However, there is a distinction between the two concepts.

For example, according to the Groovy docs:

A closure in Groovy is an anonymous
chunk of code that may take arguments,
return a value, and reference and use
variables declared in its surrounding
scope.

In functional language parlance, such an anonymous code block might be referred to as an anonymous lambda expression in general or lambda expression with unbound variables or a closed lambda expression if it didn’t contain references to unbound variables (like threshold in the earlier example). Groovy makes no such distinction.

Then according to the Wikipedia page on Closures:

The term closure is often mistakenly used to mean anonymous function.

What am I missing?

  • 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-20T15:27:57+00:00Added an answer on May 20, 2026 at 3:27 pm

    As it says in the next paragraph of the same page you linked to in the groovy docs:

    Strictly speaking, a closure can’t be
    defined. You can define a block of
    code that refers to local variables or
    fields/properties, but it becomes a
    closure only when you “bind” (give it
    a meaning) this block of code to
    variables. The closure is a semantic
    concept, like an instance, which you
    cannot define, just create. Strictly
    spoken a closure is only a closure if
    all free variables are bound. Unless
    this happens it is only partially
    closed, hence not really a closure.
    Since Groovy doesn’t provide a way to
    define a closed lambda function and a
    block of code might not be a closed
    lambda function at all (because it has
    free variables), we refer to both as
    closure – even as syntactic concept.
    We are talking about it as syntactic
    concept, because the code of defining
    and creating an instance is one, there
    is no difference. We very well know
    that this terminology is more or less
    wrong, but it simplifies many things
    when talking about code in a language
    that doesn’t “know” the difference.

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

Sidebar

Related Questions

No related questions found

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.