Mark Watson on automatic accessors for Java

Mark Watson proposes a change to the Java language, in the form of making it possible to automatically generate accessor methods for class attributes. It would work a bit like the generic functions created by the :reader, :writer and :accessor slot options given to defclass in Common Lisp.

However, I think that if that part of the language is to be changed — and I agree it should be — the new design should go all the way to hiding the methods from the users of the class. It should be possible to optionally define the accessor methods you want and then have them accessible by simply using the attribute name. So object.attribute = value would invoke object.setAttribute(value) behind the scenes, if such a method was defined. For backwards compatibility, it would need to do the normal assignment if it was permitted and no method was defined. A close relative to look at for inspiration would be C#. This one of those places where the language is, simply put, better.


Reading Bruce Eckel's great blog, I stumbled across this: The Java team is clearly not ignoring the threat of C# [...] along with the new features already on the list for "Tiger" (JDK 1.5), including true enumerations, autoboxing, and generics (templates), they are adding attributes, something (along with autoboxing) taken directly from C#, because it's a good idea.

99 bottles of GOO

Here's a version of 99 bottles written in GOO. I have submitted it.

(df bottles (n)
                (cond ((= n 0) "No more bottles")
                        ((= n 1) "One bottle")
                        (#t (cat (num-to-str n) " bottles")))
        " of beer"))

(df bow (n)
        (cat (bottles n) " on the wall"))

        (fun (n) 
                (post (bow n)) 
                (post "\n") 
                (post (bottles n)) 
                (post "\nTake one down, pass it around\n") 
                (post (bow (1- n))) 
                (post "\n\n")) 
        (range-by 100 >= 1 1-))

Happy easter.

Berkeley DB XML

I just went surfing Sleepycat Software to read some documentation (don't ask me why, I just realized I have it all installed locally), when I noticed this: Berkeley DB XML. Apparently not yet released, but interesting anyway. I'm not big on XML DBs, but with Sleepycat doing it, it might be worth checking out. At least they have a great history of doing high-quality, simple, lightweight products that just do their thing with minimum fuss. And if they continue with their licensing policy, all the better. Then we just need some Python bindings...

© Juri Pakaste 2023