Re: Java syntax extension proposal
- From: Daniel Pitts <newsgroup.spamfilter@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 25 May 2009 17:24:49 -0700
Lew wrote:
Daniel Pitts wrote:It allows a static method from one class (Let's say Foo) be called on an instance variable of another class (Let's say String).As I recall, there was a JSR proposal for something that was like a static import, but it made the static method call look like an instance call.
You can already reference a static method through an instance, but most sources I've read regard that as a bad practice. Eclipse even supports a warning about that.
How did the suggested feature differ?
For example:
// Foo.java:
class Foo {
public static String doSomething(String string) { ... }
}
// Main.java
/*Magic Static Import statment that says allow String.doSomething() to be called. Something like import migrate Foo.doSomething to String */
class Main {
public static void main(String...args) {
String myString = "This is a test";
myString.doSomething(); // Sugar for Foo.doSomething(myString)
}
}
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
.
- References:
- Java syntax extension proposal
- From: Roedy Green
- Re: Java syntax extension proposal
- From: Lew
- Re: Java syntax extension proposal
- From: Daniel Pitts
- Re: Java syntax extension proposal
- From: Lew
- Java syntax extension proposal
- Prev by Date: Re: Java syntax extension proposal
- Next by Date: Re: dates in Zip files
- Previous by thread: Re: Java syntax extension proposal
- Index(es):
Relevant Pages
|