I totally forgot this expert existed [WayBack] GExperts Help: Copy component names
–jeroen
Posted by jpluimers on 2019/05/29
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/05/29
Via [WayBack] TInterlocked.Exchange for interfaces? Since there is no System.SyncObjs.TInterlocked.Exchange overload for interfaces (and the Exchange versio… – Stefan Glienke – Google+
It has made it to this piece in [Archive.is] sglienke / Spring4D / source / Source / Reactive / Spring.Reactive.pas — Bitbucket:
class function TInterlockedHelper.Exchange<T>(var Target: T; const Value: T): T; begin Result := Default(T); PPointer(@Result)^ := Exchange(PPointer(@Target)^, PPointer(@Value)^); if Assigned(Value) then Value._AddRef; end;
It is similar to the TInterlocked.Exchange methods.
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/05/28
Since I keep forgetting this piece of IDE Fix Pack 5.92 released – DelphiFeeds.com
The new version 5.92 now binds
- Ctrl+Alt+Enter to “Find References” and introduces
- Shift+Ctrl+Alt+Enter for “Find Local References”.
No shortcut toggling anymore.
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/05/28
Interesting subject: [WayBack] I am looking for a JSON unmarshaller, that takes the JSON string and apply it to the object (and not take an object and try to apply the JSON to it). E… – Nicholas Ring – Google+
A start by Stefan Glienke: [WayBack] JsonDataObjectUnmarshall — Bitbucket
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/05/23
Interesting thread that reminded me of the relatively new FastMM feature to track down lock contention and cope with it using release stacks:
[WayBack] I try use FastMM4 to tracking bottleneck in allocating memory. I was inspired by this Primož movie: https://www.youtube.com/watch?v=p-5mJyXvmrc When I… – Jacek Laskowski – Google+
The changes by Primož have added these two new conditional defines to the FastMM4 codebase:
LogLockContentionUseReleaseStack (note this option was not documented in FastMM4Options.inc)These options are mutually exclusive.
This was the original post it got introduced in [WayBack] The Delphi Geek: Finding Memory Allocation Bottlenecks with FastMM4 and merged into the main repository.
FastMM introduction: [WayBack] The New Memory Manager In BDS 2006 – by Pierre le Riche.
It also taught me about [WayBack] RAMDisk – Software that Accelerates, Protects, Optimizes – Server Memory Products & Services – Dataram.
Primož stores his DCU files there: much faster than SSD, and far less wear on your SSD; see https://youtu.be/p-5mJyXvmrc?t=2675
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Event, FastMM, Software Development | Leave a Comment »
Posted by jpluimers on 2019/05/22
Thanks Ondrej Kelle for answering this:
uses
System.SysUtils,
Web.HTTPApp,
Soap.WebBrokerSOAP;
function TTest.CallMe: string;
var
WebDispatcher: IWebDispatcherAccess;
begin
Result := '';
if Supports(GetSOAPWebModule, IWebDispatcherAccess, WebDispatcher) then
Result := Format('You are calling me from: %s', [WebDispatcher.Request.RemoteIP]);
end;
Source: [WayBack] web services – Accessing the original TWebRequest object in a Delphi SOAP Server – Stack Overflow
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »
Posted by jpluimers on 2019/05/21
Interesting thread that shows Delphi XE8 introduced a dependency directive: [WayBack] Just curious, in which version was the dependency directive introduced? As in procedure X; external ‘somelib’ dependecy ‘otherlib’; S… – Johan Bontes – Google+
It’s documented as of XE8: [WayBack] Procedures and Functions (Delphi) – RAD Studio: Specifying Dependencies of the Library
The earliest use I could find is in XE4 source C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\source\IBX\IBIntf.pas
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/05/16
The interesting question a while back [WayBack] The Initialization-Block of a unit that is part of a package. Is it run as part of DLLMain? – Alexander Benikowski – Google+ has a simple TL;DR answer: “it depends” on the actual usage of those units.
Way more elaborate, as I dislike language stuff that you need to track down by trial and error what is actually used:
Well, seems so(in our case). Rootcall which triggers the initialization is:
ntdll.ldrLoadDLL
I did not mention, that the BPL is used by a DLL(DLL links against package) which means the package is loaded/initialized by the Os when theDLLMainruns. Odd combination but that seems to be the culprit here.David Heffernan
Yes, it is triggered fromDllMain. And yes, this has massive consequences for what can and cannot be done in initialization sections.Alexander Benikowski
+David Heffernan in my case. When a packages unit is already initialized by being used from an Exe(which links to the Package), it is not from within aDLLMain.
In my case, both the Application and the dll it loads, both link to the same package. But the unit in question is unused until the DLL is loaded.Uwe Raabe
The docs forInitializePackagesay it calls theinitializationparts of all contained units in the package – not only the used ones.David Heffernan
+Alexander Benikowski In that scenario we have load time linking and I guess the package framework handles it differently.David Millington
Related: don’t forget thatclassconstructors anddestructors effectively run in theinitializationandfinalizationsections too. Restrictions or side effects apply there too. docwiki.embarcadero.com – Methods (Delphi) – RAD StudioStefan Glienke
+Uwe Raabe Which is not being done when you use it as runtime package. Only initialization sections from unit being used are being run. This caused us several problems in the past where 2 modules (A being the host application exe and B being some DLL that gets loaded at a later point via LoadLibrary) were using a runtime package but only B used a particular unit from the package which caused the initialization code for that unit being executed when B was loaded and hence being executed in the context of thedllmainof B.The usual solution is then to put those units into some dummy unit forcing the initialization of that unit to be run in A.
Another solution according to your statement could be to call
InitializePackageon all the used runtime packages – and there the question is: couldn’t the RTL do that somehow?+Stefan Glienke I am not sure if that is desirable when done unconditionally. Even when compiled with packages I wouldn’t expect units to be initialized which aren’t actually used. That would perhaps change the behavior of the application depending on whether it is compile with runtime packages or without.
The case is different with dynamic loaded packages. The units in there are obviously not directly used in the first place. As no one can know which units of such a package are used or not, initializing all of them seems like a viable decision.
Of course there will be situations where your proposed behavior might come in handy, but I doubt that this will be a fit for all.
Source: The Initialization-Block of a unit that is part of a package. Is it run as pa…
Related:
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2019/05/15
One more thing to take away from Procedural Programming: It’s Back? It Never Went Away – Kevlin Henney [ACCU 2018] – YouTube was explained in [WayBack] How to Design Early Returns in C++ (Based on Procedural Programming) – Fluent C++.
Though in C++, it applies to all programming languages that stem from a procedural background (Pascal, C#, Java, golang, to name just a few).
The article is about keeping an if/else-if/else tree, even when they can be removed becomes some of their bodies perform an early return, as
In C++, as well as in other languages, the
returnkeyword has two responsibilities:
- interrupting control flow,
- yielding a value.
It basically comes down to this argument:
Essentially, the argument for Code #1 is that you need to know less to understand the structure of the code.
Indeed, if we fold away the contents of the if statements, Code #1 becomes this:
1234567 bool isLeapYear(int year){if (year % 400) { ... }else if (year % 100) { ... }else if (year % 4) { ... }else { ... }}The structure of the code is very clear. There are 4 different paths based on the
year, they’re independent from each other, and each path will determine the boolean result of the function (if it doesn’t throw an exception).Now let’s see how Code #2 looks like when we fold away the if statements:
12345678 bool isLeapYear(int year){if (year % 400) { ... }if (year % 100) { ... }if (year % 4) { ... }return false;}And now we know much less. Do the if statements contain a
return? Maybe.Do they depend on each other? Potentially.
Do some of them rely on the last
return falseof the function? Can’t tell.With Code #2, you need to look inside of the if statement to understand the structure of the function. For that reason, Code #1 requires a reader to know less to understand the structure. It gives away information more easily than Code #2.
–jeroen
via [WayBack] Kevlin Henney – Google+: How to Design Early Returns in C++ (Based on Procedural Programming) – Fluent C++
Posted in .NET, C, C#, C++, Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »
Posted by jpluimers on 2019/05/15
[Archive.is] Need to try this: … multiple default index properties having the same name …getters can be overloads … resolve …by type signature … – Thomas Mueller (dummzeuch) – Google+, thanks to marck for this brilliantly simple example:
private function GetColumnValue(const ColumnName: string): string; overload; function GetColumnValue(Index: Integer): string; overload; procedure SetColumnValue(Index: Integer; const Value: string); public property Values[const ColumnName: string]: string read GetColumnValue; default; property Values[ColumnIndex: Integer]: string read GetColumnValue write SetColumnValue; default; end;This means:
- you can have multiple default indexor properties
- the multiple indexor properties can have the same name e.g., Values
- the properties getters can be overloads (i.e. have the same name) e.g., GetColumnValue
- Delphi will resolve the overloads by type signature
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »