Open gewang opened 7 months ago
more thinking from PR Lab hackathon edition @nshaheed @AndrewAday @gewang
class X
{
fun static int go() { <<< "go" >>>; return 1; }
}
X x;
class Y { fun Y(float val) { X.go(); // this should be okay x.go(); // this would not be okay, due to dependency <<< val >>>; } }
class Z { fun int nooooo() { return 2; }
// this probably can't work, as static init happens
// after compile but before run code
x.go() => static int z;
// calling a member function is not allowed
nooooo() => static int a;
// this is okay because it would just be part of pre-ctor
nooooo() => a;
// constructor
// could throw runtime exception if time-advance detect
// compile time if dependencies don't work out
// this line needs to be marked as being run before this file
// need to generate a VM-code-block to run static stuff immediate
// after compile, before file code is run
static Y why(440);
}
Java allows static function calls and constructors in static variable declarations, but not member functions. Static variables can also be modified in static functions,
public class MyClass {
static int p = 0;
static MyClass fajioe = new MyClass();
public static void main(String args[]) {
int x=10;
int y=25;
int z=x+y;
System.out.println("Sum of x+y = " + z);
}
public static int test() {
System.out.println("jfioesjfioe");
System.out.println(p);
return 11;
}
public static int foo = test();
public MyClass() {
System.out.println("ssssss");
p = 4;
}
}
for class static UGen connect or constructors in general, detect for time-advance and throw exception if detected
class DEELAY extends UGen
{
fun DEELAY()
{
2::second => now;
<<< "constructor" >>>;
}
}
DEELAY dl => dac;
<<< "after connect" >>>;
possible semantics and process: 1) identify lines with
static
variables 2) disallow bothstatic
and non-static variables in the same line 3) disallow time-advance (could be a compiler error or a runtime exception for immediate mode violation) (e.g.,1::second => static dur a => now;
) 4) run the static lines a) at compile-time if public class OR b) at run-time if non-public class