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 1,619 other followers

Archive for the ‘Spring4D’ Category

Interface methods are not assignment compatible with method references or methods of object.

Posted by jpluimers on 2019/04/02

Boy I wish that QC was still up and QualityPortal was publicly indexable as that would have saved me quite a bit of time tracking this down. Luckily I got help from Stefan Glienke (who maintains the awesome Spring4D library based on modern Delphi compiler support) when I mentioned

How good are you with reference to function?
I’ve an odd compiler thing throwing errors when using interfaces but not with classes.

So, for posterity:

Unlike C#, in Delphi interface methods are not compatible with method references or methods of object.

This has many manifestations, which means you can get a variety of compiler errors. I’ve listed the ones I could find below, but presume there are more and if I find more will update this post.

These are the errors you can get:

  • E2010 Incompatible types: ‘T’ and ‘Procedure’
  • E2035 Not enough actual parameters
  • E2250 There is no overloaded version of ‘FirstOrDefault’ that can be called with these arguments

These are the (now defunct, but used to be publicly accessible) QC and QualityPortal (needs sign on) entries (thanks Stefan Glienke and Blaise Thorn for reporting these):

The really frustrating part is that the RSP is marked as “new feature” whereas clearly it isn’t, so it probably never will be fixed.

A workaround for now is to wrap the interface method references with:

  • either anonymous methods (when you have just a few classes to cover, but maybe more than a few methods on the interface)
  • or instance methods on a class (when there are many classes to cover and preferably few methods on the interface)

Examples are in the code below that also shows this works fine and dandy in C#.

–jeroen

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 10.2 Tokyo (Godzilla), Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development, Spring4D | Leave a Comment »

When I ever go and use the Spring4D activator, these are some URLs I need to re-read

Posted by jpluimers on 2019/03/27

When I ever go and use the Spring4D activator, these are some URLs I need to re-read:

–jeroen

Posted in Delphi, Development, Software Development, Spring4D | Leave a Comment »

Spring4D How to correctly assign NULL to a Nullable type?

Posted by jpluimers on 2018/12/19

Since I tend to forget this: [WayBack] Spring4D How to correctly assign NULL to a Nullable type? this is correct? fDateTime = Null; or this? fDateTime := nil; – Jacek Laskowski – Google+

The preferred way is fDateTime := nil.

This is possible because of [WayBack] Delphi sorcery: How to create an operator overload that only accepts nil using a reference type (in this case interface) so no non-nil pointers can be passed:

type
  Nullable<T> = record
  strict private type
    Null = interface end;
  public
    class operator Implicit(const value: Null): Nullable<T>;
  end;

–jeroen

Posted in Delphi, Development, Software Development, Spring4D | 2 Comments »

Spring4D Conference

Posted by jpluimers on 2018/12/19

Do not forget the early bird sales ends soon for the Spring4D European Conference 2018 – Bergamo Italy, right before Easter 2019.

Both the original author and the current maintainer will be there, and it will be a great place to socialize with fellow Spring4D users.

Buy tickets: [WayBack] Spring4D Conference

Via:

–jeroen

Posted in Delphi, Development, Software Development, Spring4D | Leave a Comment »

Spring4D, Extended floating point values and Mac OS X: the 16-byte stack alignment

Posted by jpluimers on 2016/12/13

Just a few quick notes after solving a stack corruption issue in Spring4D on Mac OS X involving the Extended data type and 16-bit Stack Alignment:

–jeroen

Posted in Algorithms, Delphi, Delphi XE4, Delphi XE5, Development, Floating point handling, Software Development, Spring4D | Leave a Comment »

 
%d bloggers like this: