Reminder to self: remember which of the open source libraries have:
- a generic
TProc<T>
alike with an const values: array of const T
parameter
- a generic
TProc<T>
alike with a const value: T
parameter
Google returned none that stuck:
The Delphi RTL does not contain them, and because they forgot setting them up with const
parameters, these can never be changed:
[WayBack] System.SysUtils.TProc – RAD Studio API Documentation
TProc = reference to procedure;
TProc<T> = reference to procedure (Arg1: T);
TProc<T1,T2> = reference to procedure (Arg1: T1; Arg2: T2);
TProc<T1,T2,T3> = reference to procedure (Arg1: T1; Arg2: T2; Arg3: T3);
TProc<T1,T2,T3,T4> = reference to procedure (Arg1: T1; Arg2: T2; Arg3: T3; Arg4: T4);
More people are annoyed by this, for instance [WayBack] SysUtils.pas Why parameters of these anonymous not const? TProc = reference to procedure (Arg1: T1; Arg2: T2); TProc = reference … – Jacek Laskowski – Google+
SysUtils.pas
Why parameters of these anonymous not const?
TProc<T1,T2> = reference to procedure (Arg1: T1; Arg2: T2);
TProc<T1,T2,T3> = reference to procedure (Arg1: T1; Arg2: T2; Arg3: T3);
TFunc<T,TResult> = reference to function (Arg1: T): TResult;
TFunc<T1,T2,TResult> = reference to function (Arg1: T1; Arg2: T2): TResult;
-
Because the designer made a bloody terrible mistake
-
To be fair, const-ness is a bloody mess in Delphi…
-
It could have been solved if the const’ness had been seen as a implementation detail by the compiler (which it really is) and made const and non-const signatures assignment compatible.
-
-
+Marco Cantu Any chance of a compiler improvement in the future with regards to relaxing const matching in signature assignments…? :)
-
I’ve taken to defining
TConstProc<T1,T2> = reference to procedure (const Arg1: T1; const Arg2: T2);
for cases where I have full control.
-
+Vincent Parrett I’m sure we all have our own versions of this. But it’s not much use for composition of course.
-
+David Heffernan Yup. Since it’s unlikely the compiler will every be updated to make const an automatic thing, perhaps they could add const versions to the RTL.
-
Yeah, we end up making our own versions of these to add the consts in all our projects.
-
Do file a QP, please. Major releases like the upcoming 10.3 are the time to make interface-breaking changes.
–jeroen