The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,419 other followers

delphi “tproc” with “array of const” – Google Search

Posted by jpluimers on 2020/12/08

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;

  • David Heffernan's profile photo
    Because the designer made a bloody terrible mistake 
  • Asbjørn Heid's profile photo
    To be fair, const-ness is a bloody mess in Delphi…
  • Hallvard Vassbotn's profile photo
    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.
  • David Heffernan's profile photo
    +Hallvard Vassbotn indeed, and it pains me that this has never happened
  • Hallvard Vassbotn's profile photo
    +Marco Cantu Any chance of a compiler improvement in the future with regards to relaxing const matching in signature assignments…? :)
  • Vincent Parrett's profile photo
    I’ve taken to defining
    TConstProc<T1,T2> = reference to procedure (const Arg1: T1; const Arg2: T2);for cases where I have full control.

  • David Heffernan's profile photo
    +Vincent Parrett I’m sure we all have our own versions of this. But it’s not much use for composition of course.
  • Vincent Parrett's profile photo
    +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.
  • Allen Drennan's profile photo
    Yeah, we end up making our own versions of these to add the consts in all our projects.
  • David Millington's profile photo
    Do file a QP, please. Major releases like the upcoming 10.3 are the time to make interface-breaking changes.

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: