Does the type system support static fields?


Java has support for what it calls a static field. This is a class field whose value is shared among every instance of the class. This can be useful for things like keeping track of the number of class instances and holding the value of a class constant.

Does the type system support static fields or something similar? If so how do you declare a field static?


While the c3 platform is fundamentally stateless (distributed systems and all that) there are ways to achieve similar effects:

  1. Use a singleton, e.g. make an instance of your type with id: “this is the singleton”, then when you want to get/update the ‘static field’ instead fetch and update the singleton instance
  2. Use type.fetchCount() to get the count of a particular type in the DB

Is there a particular problem you’re trying to solve? In general, writing distributed applications requires new patterns for solving old problems.


I was trying to make a universal boolean status flag for a type I was making, and was wondering how to go about it. The first method you listed would definitely have worked. I have since found a way to solve my problem without the flag.