2016-04-18 11:42 GMT+02:00 Anthony Walter <[email protected]>: > Do the source and dest types need to match? >
Yes. > How about:"CopyFrom"? As it is right now you already have type parity > between types such as floats <- integer and string <- char, so why not > between TBar <- TFoo? > > class procedure TBar.CopyFrom(constref Source: TFoo; var Dest: TBar); > > Then this begs question, what's the difference between AutoCopy/CopyFrom > and: > > class operator TBar.Implicit(const Value: TFoo): TBar; > Management operators works in different way than standard operators. Any of management operator is strictly related to RTL code (system.pp), for record with management operators is exclusively created small kind of VMT for RTL purposes. In generally set of management operators can't be changed. Existence of - class operator Initialize(var aFoo: TFoo); - class operator Finalize(var aFoo: TFoo); - class operator [Copy|OtherName](constref aSrc: TFoo; var aDst: TFoo); - class operator [AddRef|OtherName](var aFoo: TFoo); is strictly required. That is because: 1. Performance (especially AddRef operator for dynamic arrays - see my example for Florian) 2. Cooperation with RTL functions like New/Dispose, Initialize/Finalize, InitializeArray, FinalizeArray, TObject.InitInstance/TObject.CleanupInstance 3. Related to previous point: We need to cover actions for runtime, at compile time is impossible to cover all usages of records (like dynamically created instances of records, for example for scripts purposes). -- Best regards, Maciej Izak
_______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
