Where each Dew.Math type may be declared:
| Declaration context | Value types (Vector, Matrix, VectorInt, MatrixInt) | Class types (TVec, TMtx, TVecInt, TMtxInt) |
|---|---|---|
| Local variable | YES (primary use) | YES — with CreateIt/FreeIt |
| Class/record field | NO — never | YES — with constructor/destructor |
Rule 1: Value types must only be local variables. Never use them as fields.
Rule 2: Class types as fields — use constructor + destructor (not CreateIt/FreeIt):
class Something : IDisposable {
TVec FData;
public Something() { FData = new TVec(); }
public void Dispose() { MtxVec.FreeIt(ref FData); }
}
Rule 3: CreateIt / FreeIt are for local objects only — never for fields.
StringList — value type for string lists (unit: StringVar)
StringList is a value-type record wrapper around TStringList. It has the same API as TStringList (Add, Delete, LoadFromFile, SaveToFile, Count, Strings[], Text, Sort, Find, IndexOf, etc.) but requires no Create or Free — the compiler manages its lifetime automatically via an internal interface reference.
Use StringList instead of TStringList to avoid Create/Free boilerplate. It can be used as a local variable or as a field in classes or records. Unlike Vector/Matrix, StringList has no memory pool caching — each instance manages its own internal TStringList via interface reference counting.
// C#: same pattern
var sl = new StringList();
sl.Add("line 1");
sl.Add("line 2");
sl.SaveToFile("output.txt");
// freed automatically
StringList auto-converts to TStrings and TStringList via implicit operators, so it can be passed directly to any method expecting those types.
See also: topic type-selection for choosing between value types and class types.