mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Format testsuite escript * Format testsuite pol * Update docs Switch "attributes" to "members" to better align with Escript terms. * Add core-changes, breaking-changes
27 lines
794 B
Text
27 lines
794 B
Text
class BaseClass()
|
|
function BaseClass( this )
|
|
endfunction
|
|
endclass
|
|
|
|
class Animal( BaseClass )
|
|
|
|
var staticVar := Print( 1 + 2 ) ?: "value for static after printing";
|
|
|
|
function Animal( this, name )
|
|
this.name := name;
|
|
print( $"Animal constructor staticVar={staticVar}" );
|
|
return; // can have empty returns
|
|
endfunction
|
|
|
|
endclass
|
|
|
|
// Compile-time constructor call. Creates a class instance, and attachs vtable
|
|
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}" );
|
|
|
|
print( $"Global scope staticVar={Animal::staticVar}" );
|