Nothing pollutes java source more than getters and setters. I can't believe this still isn't being address. Wish they'd move in the direction Groovy has in this regard.
Java 9 features announced
171–180 of 228 posts
Re: Java 9 features announced
#172Nothing pollutes java source more than getters and setters. I can't believe this still isn't being address. Wish they'd move in the direction Groovy has in this regard.
Although I prefer not using getters & setters at all.
Re: Java 9 features announced
#173Nothing pollutes java source more than getters and setters. I can't believe this still isn't being address. Wish they'd move in the direction Groovy has in this regard.
Re: Java 9 features announced
#174Re: Java 9 features announced
#175Nothing pollutes java source more than getters and setters. I can't believe this still isn't being address. Wish they'd move in the direction Groovy has in this regard.
Re: Java 9 features announced
#176Re: Java 9 features announced
#177Nothing pollutes java source more than getters and setters. I can't believe this still isn't being address. Wish they'd move in the direction Groovy has in this regard.
Not exactly comparable (because everything is immutable), but Haskell has sort of a cool approach to setting and getting fields. Let's say you have data Point = Point {x :: Int, y :: Int} If you have a Point object called "point", you can get x by doing x_coord = x point If you want to create a new Point with x set to 5, you can do point' = point {x = 5}
type point = { x: int; y:int}
let z = {x = 5; y = 10}
let y = {z with x = 17}Re: Java 9 features announced
#178Earlier quoted context omitted.
Awesome! Thanks. I don't know much about the path from idea to standardized feature with the JVM. Is there hope for it in Java 9 or is this much farther out in the future? Probably first and more importantly, what is the chance for this even ever happening?
"the path from idea to standardized feature" Guy Steele was asking for value types in 1998 ( http://www.cs.virginia.edu/~evans/cs655/readings/steele.pdf )
Re: Java 9 features announced
#179Nothing pollutes java source more than getters and setters. I can't believe this still isn't being address. Wish they'd move in the direction Groovy has in this regard.
Re: Java 9 features announced
#180I had heard a rumor that there ware talks of user defined value types. Does anyone know if there is any hope for this?
What JVM instructions would you use to implement user-defined value types?
"user-defined value types", i.e. structs, can already be done today by (ab)using the Flyweight pattern and storing data (possibly off-heap with RAII rather than GC semantics) in some byte[].
All a JDK-supplied implementation would really need to do is (1) automate/hide all the painful work necessary to set this up and (2) provide syntactic sugar in the form of operators that can directly manipulate members of these types (+fast implicitly inlined implementations of them, specialized on the member types).