|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Static Initializer in Joe-EI believe Joe-E should disallow calls to static methods in static initializers for the same reason that it forbids calls to instance methods in constructors. The following is an example of what can go wrong if you let static initializers invoke static methods. In this example, method m, which is verified to be pure by Joe-E, returns two different results given the same input (m takes no inputs). import org.joe_e.Immutable; public class InitializerBlock implements Immutable { public final static int a; public final static int d; static { int a1 = m(); a = 1; int a2 = m(); d = a2 - a1; } static int m() { return a; } public static void main(String[] args) { assert InitializerBlock.d == 0; } } _______________________________________________ e-lang mailing list e-lang@... http://www.eros-os.org/mailman/listinfo/e-lang |
|
|
Re: Static Initializer in Joe-EMohsen Vakilian wrote:
> I believe Joe-E should disallow calls to static methods in static > initializers for the same reason that it forbids calls to instance methods > in constructors. > > The following is an example of what can go wrong if you let static > initializers invoke static methods. In this example, method m, which is > verified to be pure by Joe-E, returns two different results given the same > input (m takes no inputs). I agree; your example is convincing. -- David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com _______________________________________________ e-lang mailing list e-lang@... http://www.eros-os.org/mailman/listinfo/e-lang |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |