2

Can the following class be generated using Clojure's gen-class macro?

public class Test {
    public static final String TEST_NAME = "This test's name.";
}

If not, why not?

  • `why not?` Because that's not the purpose of Clojure. – Ankur Apr 27 '13 at 17:06
  • How might one distinguish the 'purpose' of clojure with respect to the existence of gen-class when it doesn't support for static fields? In other words: Why provide the facility to create raw java classes without providing the mechanism for setting static fields. I'm not picking a fight. I really like Clojure. I just can't seem to find anywhere a rationale for this decision. – Jon Seltzer Apr 28 '13 at 02:27
  • Gen-class is for introp, that is it attempts to give you the power to create the kind of classes demanded by other java libs. It is rare for a java lib to require you provide a class with a particular static field. – Chouser Apr 28 '13 at 04:53
  • Thank you. That's the best explanation I've seen. – Jon Seltzer Apr 28 '13 at 11:30
  • Well, then, I'll just copy that on down... – Chouser Apr 28 '13 at 15:14

1 Answers1

1

No, gen-class can't generate static fields because gen-class is for introp. It attempts to give you the power to create the kind of classes demanded by other java libs. It is rare for a java lib to require that you provide a class with a particular static field.

Chouser
  • 5,093
  • 1
  • 32
  • 24