Google Groups Home
Help | Sign in
doubt
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
snanub...@gmail.com  
View profile
 More options Feb 11, 6:30 am
From: snanub...@gmail.com
Date: Mon, 11 Feb 2008 03:30:25 -0800 (PST)
Local: Mon, Feb 11 2008 6:30 am
Subject: doubt
Hi,

What is the purpose of  'Closure'  in Groovy ?

We are just defining it and calling it , like a normal function.

Anyone, Please clarify my doubt.

Thanks,
Sridevi.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ajith George  
View profile
 More options Feb 11, 7:42 am
From: "Ajith George" <ajithkgeo...@gmail.com>
Date: Mon, 11 Feb 2008 18:12:56 +0530
Local: Mon, Feb 11 2008 7:42 am
Subject: Re: [IGGUG:27] doubt

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 many ways it resembles anonymous inner classes in Java, and
closures are often used in Groovy in the same way that Java developers use
anonymous inner classes. However, Groovy closures are much more powerful
than anonymous inner classes, and far more convenient to specify and use.

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.

Strictly spoken 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.

See http://groovy.codehaus.org/Closures  for more details.

Thanks,

Ajith.

On Feb 11, 2008 5:00 PM, <snanub...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rajmahendra  
View profile
 More options Feb 12, 6:51 am
From: Rajmahendra <rajmahen...@gmail.com>
Date: Tue, 12 Feb 2008 03:51:32 -0800 (PST)
Local: Tues, Feb 12 2008 6:51 am
Subject: Re: doubt
hi...

Check out this one.....  ;-)

http://www.vitarara.org/cms/closures_and_bindings_in_groovy

On Feb 11, 4:30 pm, snanub...@gmail.com wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google