Hacker News new | past | comments | ask | show | jobs | submit login

The Person example also seems overly verbose. Does the equivalent Clojure example have private attributes name and age? It looks like the author is accessing the name and age attribute directly instead of using getter methods as defined in the Java version.

    class Person {
        String name;
        int age;
        Person(String name, int age) {this.name = name; this.age = age}
    }
This is still more verbose than the (defrecord person [name age]) but still, I agree with the dodgy examples used.

Disclaimer : I don't know Clojure or similar and therefore I could be missing something. I did a quick search for defining private attributes in Clojure but didn't find any good hits.




There are definitely some in the Java community who would view public properties as incorrect code. For example, it was not accepted at the large corporation where I used to work, nor is it allowed in my wife's Intro to Java class. There are some cultural language specifications as well as the technical ones.


It doesn't usually make any sense to speak of getter methods in Clojure. Records are immutable after construction.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: