Open armoha opened 1 year ago
Actually I started to lose interest in making static
field as public API. It complicates the language but does not hold much weight. e.g. ancient version of Rust had immutable struct field but later dropped it.
It's mostly solved in euddraft 0.9.10.2.
We need to expand
EUDStruct
to fully port current behavior ofStringBuffer
and prevent performance regression.Highly related to armoha/euddraft#58
Background
constructor
andconstructor_static
Default implementation of
constructor_static
callsconstructor
too, but user is free to override it to make specialized and separate code for static declaration:Motivation
We want to pass
StringBuffer
to function but we don't want to makeStringBuffer
too slow.StringBuffer.StringIndex
,.epd
and.capacity
should bestatic
.StringIndex
: map string idStringBuffer
uses.epd
: starting address of string content.capacity
: every string has fixed capacity and can't reallocate (Changing starting offset of string is not supported in StarCraft: Remastered. Starting addresses of every strings are fixed.)It is breaking change to make
var
field toconst
orstatic
field. It is okay to changestatic
field toconst
orvar
field.Field mutability
var
fieldconst
fieldconst
, the field can't be reassigned once it's initialized.UnitGroup
andEUDBag
(once it'sgroup.add(cunit)
ed, you can't further mutate.)static
fieldstatic
field access always happens in compile time whenobject
is known in compile time. No runtime cost.constructor_static
.static
field.Object.alloc
is not allowed whenObject
has any static fieldHow to implement
EUDStruct.__init__
위에는
객체.cast(인스턴스)
하는거 (_from이 있을 때) 아래는객체(인자)
정적 선언하는거 (else:)constructor_static
에서static
필드를setattr
한 걸 모아서super(ExprProxy).__init__
에 사용하는EUDVArray
의 초기값으로 넣기(maybe we need to use
Forward()
?)._initialized
._initialized == True
면인스턴스.필드 = 값;
을 하면VArray[필드인덱스] = 값
코드가 된다 (없는 필드를 대입하면 컴파일 오류)._initialized
가 없으면 일반적인 파이썬 코드처럼self.__dict__[필드] = 값
임Q. allow mutations only within
constructor_static
?Q. optimize global object initialization?
obj_global
은 1, 2, 3 대입하는 트리거를 만드는 대신에EUDVArray
의 초기값을[1, 2, 3]
으로 넣으면 좋을 듯obj_local
은var
필드인.a
와const
필드인.b
에 1, 2 대입하는 트리거를 꼭 만들어야함Q. change
.constructor
,.constructor_static
and.destructor
to static methods in epScript? (No@EUDMethod
)This will be breaking change that every constructors and destructors will duplicate codes, and users need to migrate to make separate methods and calling them on ctors and dtors to get previous behaviors.
Q. do we need
static if
?