2024-08-18 11:03:01 +02:00
|
|
|
class BaseClass()
|
2024-10-08 21:53:30 +02:00
|
|
|
function BaseClass( this )
|
|
|
|
|
endfunction
|
2024-08-14 12:56:36 +02:00
|
|
|
endclass
|
2024-08-10 15:27:25 +02:00
|
|
|
|
|
|
|
|
class Animal( BaseClass )
|
|
|
|
|
|
2024-10-08 21:53:30 +02:00
|
|
|
var staticVar := Print( 1 + 2 ) ?: "value for static after printing";
|
2024-08-10 15:27:25 +02:00
|
|
|
|
|
|
|
|
function Animal( this, name )
|
|
|
|
|
this.name := name;
|
|
|
|
|
print( $"Animal constructor staticVar={staticVar}" );
|
2024-08-18 11:03:01 +02:00
|
|
|
return; // can have empty returns
|
2024-08-10 15:27:25 +02:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
endclass
|
|
|
|
|
|
2024-08-29 11:19:29 +02:00
|
|
|
// Compile-time constructor call. Creates a class instance, and attachs vtable
|
2024-08-10 15:27:25 +02:00
|
|
|
var compile_obj := Animal( "compile-time ctor call" );
|
|
|
|
|
print( $"compile_obj={compile_obj}" );
|
|
|
|
|
|
|
|
|
|
// Run-time constructor call. Does not attach vtable in this scenario, but calls the user function
|
|
|
|
|
var runtime_obj := dictionary{};
|
|
|
|
|
@Animal( runtime_obj, "runtime ctor call" );
|
|
|
|
|
print( $"runtime_obj={runtime_obj}" );
|
|
|
|
|
|
2024-08-11 23:01:38 +02:00
|
|
|
print( $"Global scope staticVar={Animal::staticVar}" );
|