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,854 other subscribers

Archive for the ‘Delphi’ Category

Delphi What’s new history and a docwiki URL trick

Posted by jpluimers on 2020/08/05

One of the great things about the Delphi docwiki structure is that the naming system is very consistent.

The consistency helps you quickly finding the What’s new for any version, just by getting the latest first.

Getting the latest one is based based on a docwiki redirection trick that always redirects from an “unversioned” URL to the latest one.

So these two “unversioned” URLs always get you there:

When writing this, the above links got me the below list. For consistency (as you cannot save URLs for prior versions in the WayBack machine because a brain-dead robots.txt setting which archive.is luckily ignores):

By now, there will hopefully be a few more Delphi versions released.

Reminder to self: update the list (:

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, History, Software Development | Leave a Comment »

Bogus W1036 ? 

Posted by jpluimers on 2020/07/30

Reminder to self for checking if this still fails:

[WayBack] Bogus W1036 ? Documentation: … “If you do not explicitly initialize a global variab… – Stefan Glienke – Google+

Documentation: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Variables_(Delphi)

“If you do not explicitly initialize a global variable, the compiler initializes it to 0.”

{$APPTYPE CONSOLE}

var
  i: Integer;
begin
  Writeln(i);
end.

Error:

[DCC Warning] Project1.dpr(6): W1036 Variable 'i' might not have been initialized

–jeroen

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

Why Rubber Ducking is good

Posted by jpluimers on 2020/07/28

I like it when people find out that Rubber Ducking is a good thing.

Read the story at [WayBack] … I’ve read about ‘rubber ducking’ and thought of it as a good thing, but I never really use/did it. Also I knew that SO showed me the value of MCVE,… – Mike Torrettinni – Google+

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Yes Delphi does some type inference on generic method calls

Posted by jpluimers on 2020/07/23

Delphi does indeed so some type inference as Primoz found out below. It has been doing this for a long time, improved over time, but has a long road ahead.

One odd thing is that generics (and the majority of inference support) were introduced in Delphi 2009 ([WayBack] Generics with Delphi 2009 Win32), but the inference was already documented in Delphi 2007: [WayBack] Delphi 2007 – Declaring Generics: Parameterized Types

This is a reminder to myself to write some more example code on what kinds of inference work and which do not, especially because of the comments from David Heffernan, Marco Cantu and Stefan Glienke, especially since the improvement over time has been small. I am curious to see how the promised “working on it” by now lives up to reality.

David Heffernan
This is a rare piece of code where type inference actually works. Mostly it does not which is very frustrating.

It’s a little ironic that you ask why you don’t need to include <T>. Normally people ask about the much more frequent instances where you do need to include <T> because the compiler’s type inference is so weak.

David Heffernan
+Marco Cantù Much more commonly there are times when you want the compiler to infer the type, but it won’t. It would really make a difference to us if the compiler was better at this.

Marco Cantù
+David Heffernan I tend to agree the compiler should be much better at type inference. Working on it!

Stefan Glienke
Infering the generic argument from a constructed generic type would be great.

GuessTheType<T>(const x: TArray<T>);

var
  a: TArray<Integer>;
begin
  GuessTheType(a);

does not work although the compiler could infer the parameter for GuessTheType from its x parameter but currently it does not know that a originally was a TArray<T> (yes, I know array of T as signature works but that is a different thing).

P.S. +Marco Cantù btw how hard can it be to finally implement generic standalone routines without that ugly static type? Probably one of the highest voted feature requests: https://quality.embarcadero.com/browse/RSP-13724)

Source: [WayBack] Anybody here knows since when we don’t have to write when calling generic ProcSomething(param: T)? It was brought to my attention today that the… – Primož Gabrijelčič – Google+

–jeroen

A quick look into the generated assembler code proves that the type is indeed resolved correctly:

Project17.dpr.26: TGeneric.GuessTheType<Exception>(x);
0041C530 8B151C484200     mov edx,[$0042481c]
0041C536 A1F4974100       mov eax,[$004197f4]
0041C53B E84CD3FFFF       call TGeneric.GuessTheType<System.SysUtils.Exception>
Project17.dpr.27: TGeneric.GuessTheType(x);
0041C540 8B151C484200     mov edx,[$0042481c]
0041C546 A1F4974100       mov eax,[$004197f4]
0041C54B E83CD3FFFF       call TGeneric.GuessTheType<System.SysUtils.Exception>
Project17.dpr.28: TGeneric.GuessTheType(s);
0041C550 8B1520484200     mov edx,[$00424820]
0041C556 A1F4974100       mov eax,[$004197f4]
0041C55B E83CD3FFFF       call TGeneric.GuessTheType<System.SysUtils.TSimpleRWSync>

Source: https://plus.google.com/+Primo%C5%BEGabrijel%C4%8Di%C4%8D/posts/edE3YWtwY3B

view raw

readme.md

hosted with ❤ by GitHub


program Project17;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
type
TGeneric = class
class procedure GuessTheType<T>(const value: T);
end;
var
x: Exception;
s: TSimpleRWSync;
{ TGeneric<T> }
class procedure TGeneric.GuessTheType<T>(const value: T);
begin
end;
begin
TGeneric.GuessTheType<Exception>(x);
TGeneric.GuessTheType(x);
TGeneric.GuessTheType(s);
end.

view raw

project17.dpr

hosted with ❤ by GitHub

Posted in Delphi, Development, Software Development | 1 Comment »

GitHub – adaloveless/commonx: Delphi/Object Pascal Classes and Tools for just about everything and everyone.

Posted by jpluimers on 2020/07/21

Warning: I posted this without doing a proper copyright check on the linked github repository, and it looks like this library heavily copies code from copyrighted materials.

So better not use them, for one because they contain copyrighted material, and also because the copyrighted units are not current.

At least these units are Copyright by Embarcadero:

Androidapi.JNI.Environment.pas:4:{ Copyright(c) 2014 Embarcadero Technologies, Inc.      }
Better_JSON.pas:5:{ Copyright(c) 2016 Embarcadero Technologies, Inc.      }
Bluetoothcomponentthreaded.pas:4:{ Copyright(c) 2016 Embarcadero Technologies, Inc.      }
FMX.Better.Controls.pas:5:{ Copyright(c) 2011-2013 Embarcadero Technologies, Inc. }
FMX.Better.ListBox.pas:5:{ Copyright(c) 2011-2013 Embarcadero Technologies, Inc. }
Generics.Collections.Fixed.pas:5:{ Copyright(c) 1995-2014 Embarcadero Technologies, Inc. }
HTTPClient_2019.pas:6:{ Copyright(c) 1995-2018 Embarcadero Technologies, Inc. }
InetWinSocketReg.pas:5:{ Copyright(c) 1995-2012 Embarcadero Technologies, Inc. }
pngimage_fmx.pas:5:{ Copyright(c) 1995-2014 Embarcadero Technologies, Inc. }
SocketsEditor.pas:5:{ Copyright(c) 1995-2012 Embarcadero Technologies, Inc. }

Read the rest of this entry »

Posted in Delphi, Development, Software Development | 3 Comments »

logging facility in Synopse seems to be an interesting alternative to JclDebug. Need to check out how they differ in looking up the method name for tracing.

Posted by jpluimers on 2020/07/15

On my todo list, as Synops is updated more often than JCL: [WayBack] The logging facility in Synopse seems to be an interesting alternative to JclDebug: According to this StackOverflow answer, one of its features is looki… – Thomas Mueller (dummzeuch) – Google+

–jeroen

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

delphi – How to reset the download when the GetIt package manager fails? – Stack Overflow

Posted by jpluimers on 2020/07/08

Since GetIt is hardly, if at all documented, but has quite a few of problems, I will likely need to use this another time: [WayBack] delphi – How to reset the download when the GetIt package manager fails? – Stack Overflow

TL;DR:

Luis Navarro from Embacadero just explained to me:

Close the IDE, then delete the OmniThread folder from MyDocuments\Embarcadero\Studio\17.0\CatalogRepository After that, you have to edit the registry and delete also the Omnithread folder from HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\17.0\CatalogRepository\Elements

Related: [RSP-12387] GetIt does not reset the download when Delphi crashes whilst downloading. – Embarcadero Technologies

Via:

–jeroen

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

delphi – How do I build an array of const? – Stack Overflow

Posted by jpluimers on 2020/07/02

As I one day likely need to pas a dynamically created array of const from scratch (which behind the scenes actually is an array of TVarRec, where each element is, TVarRec which is a variant record that can have both values and pointers to values. So the result will be kind of a mess :)

Further reading:

Edit 20251105: also relevant is this excellent article [Wayback/Archive] Rudy’s Delphi Corner – Open array parameters and array of const which was pointed to me [W/A] at Delphi Developers

--jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Specifying the msbuild configuration for a Delphi project on the commandline – twm’s blog

Posted by jpluimers on 2020/07/02

Reminder to self: check my own build configurations as there is a difference for Delphi 2007 and Delphi >= 2009: [WayBackSpecifying the msbuild configuration for a Delphi project on the commandline – twm’s blog.

Thomas indicate that:

  • Delphi 2007 uses /p:Config=Debug (or Release)
  • Delphi 2009+ uses /p:Configugration=Debug (or Release)

From my own notes, I think Delphi >= 2009 also understands the Delphi 2007 way.

Via: [WayBack] Starting with Delphi 2007 EmBorCodera switched to msbuild for the build system. The newly introduced .dproj file used since then is a valid build script… – Thomas Mueller (dummzeuch) – Google+

References:

–jeroen

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

Delphi Exception handling code review reminders

Posted by jpluimers on 2020/06/18

I bumped into [WayBack]When an exception is nil in the exception handler – twm’s blog for some legacy code a while ago.

Some code review reminders:

  • raise Exception( is always wrong: no exception instance is created
  • Exception.Create( without a raise is wrong most of the times
  • except end is almost always wrong
  • except and finally in encompassing blocks often is a code smell

I need to check which ones are caught by [WayBack] Code Analysis Tool | FixInsight for Delphi (which is now at [WayBack] TMS Software | VCL, FMX, ASP.NET, .NET controls & components for Delphi, C++Builder & Visual Studio | TMS FixInsight Pro.)

--jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »