Basically Java 7 will look a heck of a lot like PHP.
You Won't Believe This, But The Arrow Operator Is Coming To Java 7
Yes, the -> operator. According to Danny Coward, Sun Java SE Platform Lead, Java 7 will use the arrow operator for Java Beans property access:
Danny Coward talk PDF (p.27): Reading JavaBeans properties
a.setFoo(b.getFoo());
a->Foo = b->Foo;
What's wrong with using the good old dot?
I did absolutely no further research on this and am hereby completely unqualified to address it, exactly why I will address it in my "blog", but this is retarded.
I think the "what's wrong with the dot" can be summed up by saying this is not the same thing. Dot is direct property access whereas what they are talking about with arrow is accessors (getProp()). But I will then ask what the heck is wrong with getProp()? It is convention based, so I will admit that is a bit of a bad smell, but come on, its a trivial convention and it works, do we need to "fix" everything? And even if we do fix this, what the hell is with the arrow? -> is very ugly to type, two characters, one with a shift, ughh. Yeah it's less than getProp() but still I would again not exactly call it an improvement, if you HAVE to change it, make it . . . well hell looking at the keyboard, and not choosing anything that involves whitespace, I do not see any good candidates that are not already reserved (pipe | ?).
I know smarter people than I, thankfully, are doing this for a reason, but maybe one of those smarter people can explain it better for dolt comprehension purposes?
Comments
RE: Java 7 will use the "arrow" operator, arghh
They won't use the dot because c# does. plain and simple. The dot is the proper thing to use, but they won't because it would be copying even more of the syntax than they already have. believe it or don't, it is what it is.
RE: Java 7 will use the "arrow" operator, arghh
But don't they already use the dot for direct property access? For Java the dot is not in the list of possible choices, because direct property access will not go away, I think what they want is a new way to get at accessors.
RE: Java 7 will use the "arrow" operator, arghh
It is already used for direct property access, method access, type property access, etc. It is the standard character for referencing 'something' off an object/type in a post-c++ language. Why would it be any different for a "shortcut" to getFoo() and setFoo()?
RE: Java 7 will use the "arrow" operator, arghh
that was me, forgot to login
RE: Java 7 will use the "arrow" operator, arghh
What I mean is "getFoo()" is different than ".foo". What this is designed to address is a formal convention for the "getFoo()" - it has nothing to do with the ".foo".
RE: Java 7 will use the "arrow" operator, arghh
I see what you are saying now mutt, I think, why not use dot anyway, dot for both.
But I think we need to keep direct property access and accessor access separate, if they were the same that would cause problems.
RE: Java 7 will use the "arrow" operator, arghh
In practice (using c# for the past couple of years) it is not an issue.
Yes, you technically don't know if Something.Foo is a property or a member variable, but the thing is this: it doesn't matter. The author exposed an item called Foo. You as the user don't really care if it is a shortcut to a getFoo() call or if it is the member Foo. They made the decision, knowing Foo needed to be exposed on Something.