Jose Antonio Illescas del Olmo
2011-06-27 16:53:16 UTC
After response of Jochen Theodorou I decided discuss this feature on mailing
list...
I proposed, as real Object Oriented languages (smalltalk,...) does, that
"this" on static method references the Class that receive the message
(method) instead of the Class that declare the method.
Example:
class A {
public static foo() {
println("foo: " + this);
}
}
class B extends A {}
class C extends B {}
Calling "foo" method with subclasses:
A.foo(); // class A is the "foo" message receptor
B.foo(); // class B is the "foo" message receptor
C.foo(); // class C is the "foo" message receptor
Now returns:
foo: class A
foo: class A
foo: class A
I Propose that result must be:
foo: class A
foo: class B
foo: class C
Thank you
---------- Forwarded message ----------
From: Jochen Theodorou (JIRA) <jira-yCVjj/***@public.gmane.org>
Date: Mon, Jun 27, 2011 at 4:50 PM
Subject: [jira] Closed: (GROOVY-4905) polymorphic static methods
To: jose.illescas-***@public.gmane.org
[
https://jira.codehaus.org/browse/GROOVY-4905?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
Jochen Theodorou closed GROOVY-4905.
------------------------------------
Resolution: Won't Fix
Assignee: Jochen Theodorou
"this" has already a meaning different then what you suggest in a static
context. So this change would be a breaking change. I suggest the mailing
list for further discussion, if needed
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
list...
I proposed, as real Object Oriented languages (smalltalk,...) does, that
"this" on static method references the Class that receive the message
(method) instead of the Class that declare the method.
Example:
class A {
public static foo() {
println("foo: " + this);
}
}
class B extends A {}
class C extends B {}
Calling "foo" method with subclasses:
A.foo(); // class A is the "foo" message receptor
B.foo(); // class B is the "foo" message receptor
C.foo(); // class C is the "foo" message receptor
Now returns:
foo: class A
foo: class A
foo: class A
I Propose that result must be:
foo: class A
foo: class B
foo: class C
Thank you
---------- Forwarded message ----------
From: Jochen Theodorou (JIRA) <jira-yCVjj/***@public.gmane.org>
Date: Mon, Jun 27, 2011 at 4:50 PM
Subject: [jira] Closed: (GROOVY-4905) polymorphic static methods
To: jose.illescas-***@public.gmane.org
[
https://jira.codehaus.org/browse/GROOVY-4905?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
Jochen Theodorou closed GROOVY-4905.
------------------------------------
Resolution: Won't Fix
Assignee: Jochen Theodorou
"this" has already a meaning different then what you suggest in a static
context. So this change would be a breaking change. I suggest the mailing
list for further discussion, if needed
polymorphic static methods
--------------------------
Key: GROOVY-4905
URL: https://jira.codehaus.org/browse/GROOVY-4905
Project: groovy
Issue Type: New Feature
Reporter: joseaio
Assignee: Jochen Theodorou
Nex Class Hierarchy: A < B < C
class A {
public static foo() {
println("foo: "+ this);
}
}
class B extends A {}
class C extends B {}
A.foo(); // class A is the "foo" message receptor
B.foo(); // class B is the "foo" message receptor
C.foo(); // class C is the "foo" message receptor
foo: class A
foo: class A
foo: class A
On Object Oriented "this" references message receptor (on static method is
the Class)...--------------------------
Key: GROOVY-4905
URL: https://jira.codehaus.org/browse/GROOVY-4905
Project: groovy
Issue Type: New Feature
Reporter: joseaio
Assignee: Jochen Theodorou
Nex Class Hierarchy: A < B < C
class A {
public static foo() {
println("foo: "+ this);
}
}
class B extends A {}
class C extends B {}
A.foo(); // class A is the "foo" message receptor
B.foo(); // class B is the "foo" message receptor
C.foo(); // class C is the "foo" message receptor
foo: class A
foo: class A
foo: class A
On Object Oriented "this" references message receptor (on static method is
foo: class A
foo: class B
foo: class C
--foo: class B
foo: class C
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira