Is there a difference between these two function definitions?

View: New views
6 Messages — Rating Filter:   Alert me  

Is there a difference between these two function definitions?

by geossscripting :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Is there a difference between a function defined like this :

def myfunc(def param) {
// whatever
}

and

def myfunc(param) {
// whatever
}
? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Re: Is there a difference between these two function definitions?

by HamletDRC :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Both create a method named myfunc with an Object parameter named param
on the Script class.

You can see this using the groovyConsole "Inspect Ast" feature in the
nightly build of 1.7.

--
Hamlet D'Arcy
hamletdrc@...



On Wed, Jul 1, 2009 at 1:28 PM, Lex Williams<lyon2003@...> wrote:

>
> Is there a difference between a function defined like this :
>
> def myfunc(def param) {
> // whatever
> }
>
> and
>
> def myfunc(param) {
> // whatever
> }
> ? --------------------------------------------------------------------- To
> unsubscribe from this list, please visit:
> http://xircles.codehaus.org/manage_email

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


--
Hamlet D'Arcy

Parent Message unknown Re: Is there a difference between these two function definitions?

by geossscripting :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




So the methods are not equivalent?


---------[ Received Mail Content ]----------

Subject : Re: [groovy-user] Is there a difference between these two function definitions?

Date : Wed, 1 Jul 2009 14:40:04 -0500

From : "Hamlet D'Arcy"

To : user@...



Both create a method named myfunc with an Object parameter named param

on the Script class.



You can see this using the groovyConsole "Inspect Ast" feature in the

nightly build of 1.7.



--

Hamlet D'Arcy

hamletdrc@...







On Wed, Jul 1, 2009 at 1:28 PM, Lex Williams wrote:

>

> Is there a difference between a function defined like this :

>

> def myfunc(def param) {

> // whatever

> }

>

> and

>

> def myfunc(param) {

> // whatever

> }

> ? --------------------------------------------------------------------- To

> unsubscribe from this list, please visit:

> http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------

To unsubscribe from this list, please visit:



http://xircles.codehaus.org/manage_email





--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Re: Is there a difference between these two function definitions?

by HamletDRC :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> So the methods are not equivalent?

I think they are equivalent. The AST for the two don't seem to differ at all.


On Wed, Jul 1, 2009 at 3:19 PM, Lex Williams<lyon2003@...> wrote:

>
>
>
> So the methods are not equivalent?
>
>
> ---------[ Received Mail Content ]----------
>
> Subject : Re: [groovy-user] Is there a difference between these two function
> definitions?
>
> Date : Wed, 1 Jul 2009 14:40:04 -0500
>
> From : "Hamlet D'Arcy"
>
> To : user@...
>
>
>
> Both create a method named myfunc with an Object parameter named param
>
> on the Script class.
>
>
>
> You can see this using the groovyConsole "Inspect Ast" feature in the
>
> nightly build of 1.7.
>
>
>
> --
>
> Hamlet D'Arcy
>
> hamletdrc@...
>
>
>
>
>
>
>
> On Wed, Jul 1, 2009 at 1:28 PM, Lex Williams wrote:
>
>>
>
>> Is there a difference between a function defined like this :
>
>>
>
>> def myfunc(def param) {
>
>> // whatever
>
>> }
>
>>
>
>> and
>
>>
>
>> def myfunc(param) {
>
>> // whatever
>
>> }
>
>> ? --------------------------------------------------------------------- To
>
>> unsubscribe from this list, please visit:
>
>> http://xircles.codehaus.org/manage_email
>
>
>
> ---------------------------------------------------------------------
>
> To unsubscribe from this list, please visit:
>
>
>
> http://xircles.codehaus.org/manage_email
>
>
>
>
>
> --------------------------------------------------------------------- To
> unsubscribe from this list, please visit:
> http://xircles.codehaus.org/manage_email



--
Hamlet D'Arcy
hamletdrc@...

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


--
Hamlet D'Arcy

Re: Is there a difference between these two function definitions?

by Jochen Theodorou :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lex Williams schrieb:
>
> So the methods are not equivalent?

hehe, I was wondering if you would ask that... If you give the parameter
a def or not doesn't matter, it is the same

bye blackdrag

--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Parent Message unknown Re: Is there a difference between these two function definitions?

by geossscripting :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




Thanks for making things clear Jochen. Sorry for the beginner-level questions.


---------[ Received Mail Content ]----------

Subject : Re: [groovy-user] Is there a difference between these two function definitions?

Date : Thu, 02 Jul 2009 00:15:01 +0200

From : Jochen Theodorou

To : user@...



Lex Williams schrieb:

>

> So the methods are not equivalent?



hehe, I was wondering if you would ask that... If you give the parameter

a def or not doesn't matter, it is the same



bye blackdrag



--

Jochen "blackdrag" Theodorou

The Groovy Project Tech Lead (http://groovy.codehaus.org)

http://blackdragsview.blogspot.com/





---------------------------------------------------------------------

To unsubscribe from this list, please visit:



http://xircles.codehaus.org/manage_email





--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email