Not all for loops are created equal.
Consider
for x in [value1, value2, value3]
You would expect to see x vary in the order of the values in the list.
However – if x and the values are of an enumerated type, looping the “list”
does NOT loop in the apparent order of the constant, but in the order of the enumerated type declaration, such as it would for any set.
Category: Delphi
Software Development using Delphi
Delphi: Pitfalls of Anonymous methods and Capture
I was writing a web request handler when I ran into a problem. I was plugging in multiple handlers, but only one of them actually worked.
Why?
To get to the essence of it, this doesn’t work
procedure TMyClass.Setup;
var
Handler: THandlerClass;
hType: THandlers;
begin
Broker.Clear;
for hType in [foo, bar]
do begin
case hType of
foo: Handler := TFoo.Create;
bar: Handler := TBar.Create;
end;
Broker.AddHandler(Handler.OnHandle);
end;
end;
Zipped example source code: https://drive.google.com/open?id=1RxOxOlYOrjqPryW7vGNw40VTLav6IN_M
Continue reading “Delphi: Pitfalls of Anonymous methods and Capture”Delphi Developers Archive (Experimental)
Delphi Developers Archive (Experimental)
https://delphi-developers-archive.blogspot.com
The posts are searchable by tag list or free text search.
FYI – This is work in progress, and I hope to improve the following issues:
– Some posts have erroneous titles
– Some posts are missing attribution of the original poster
– Some 600 posts are missing due to an inexplicable quota error during import
Comments on the archived posts are currently disabled until the import is finalized.
We are looking for an experienced Delphi developer for a permanent position in our Industrial IT team at TINE SA,…
We are looking for an experienced Delphi developer for a permanent position in our Industrial IT team at TINE SA, Norway’s largest dairy product company.
About TINE: https://www.tine.no/english
Language and Location requirements
You must be able to speak/read/write Norwegian and English fluently, and be able to work at TINE’s offices at Kalbakken in Oslo.
Coding skills you need
– Modern Delphi OOP code with generics and attributes
– Delphi VCL / Windows APIs / FireDAC
– MS SQL Server T-SQL and SQL queries in general
– Basic http/tcp/udp networking
– XML/JSON knowledge
Coding skills that would be nice
– Delphi FireMonkey on iOS/Android
– MSVS C#/.NET
– MS PowerShell
– HTML5/JS/CSS
Bonus skills that come in handy
– Datawarehousing and big data
– IoT (the buzz, the hype, the stuff that works)
– Knowledge of the various aspects of Logistics and exchanging information between actors (GS1)
– Jira/SVN/git experience
Person skills we really appreciate
– Open and honest and not afraid to speak your mind
– Able to communicate clearly in writing
– Works well with others and can take and give positive feedback
– Willing to learn and adapt, as well as share and mentor
– Able to focus on and prioritize tasks, putting need before cool/fun
You have been programming for a while and can document your experience.
Please send your questions to
lars.fosdal (at) http://tine.no
Please note: Official posting will come later.
New official Embarcadero forums online
New official Embarcadero forums online
http://community.idera.com/developer-tools/
The sign-up/login is a bit prickly at first, so keep your login name / login email and password at hand, and request a password reset if your get into problems.
I wrote a function to make JSON more readable, and naturally I wonder if I missed something crucial so that it…
I wrote a function to make JSON more readable, and naturally I wonder if I missed something crucial so that it eventually will break?
There are probably more efficient ways to work with strings than concatenating character by character, but performance was not a key goal.
I hereby commit it to public code review 😉
Considering that we now can have constants within records and classes –
Considering that we now can have constants within records and classes –
why can’t we have resource strings in there?
type
TMyRec = record
const
ThisIsOK = ‘String’;
resourcestring <- [dcc32 Error] : E2029
ThisIsNotOK = ‘string’;
end;
[dcc32 Error] : E2029 ‘END’ expected but ‘RESOURCESTRING’ found
Reminder: When you need help, please be specific and remember to tell us:
Reminder: When you need help, please be specific and remember to tell us:
– Version of Delphi incl. ver.no (D5, D2006, XE3, XE8, Seattle 10.0.x, Berlin 10.1.x, Tokyo 10.2.x, etc.)
– SKU (Community, Pro, Enterprise, Architect)
– Platform (Windows, iOS, Android, Linux)
– Tech (console, VCL, FMX, etc)
– Database platform (ADO, dbExpress, FireDAC, etc)
– Database (MSSQL, MySQL, Oracle, SQLite, etc)
Also see: https://plus.google.com/+LarsFosdal/posts/NarwjyzC4rN
Where do you place your unit uses?
Where do you place your unit uses?
Over the years, I’ve come to preferring to place my uses in the Interface section only, even if its types, constants or methods only are used in the implementation section.
What is your practice, and why do you prefer one pattern over the others – or why would you recommend against one of these patterns?
unit Test;
interface
uses
ThisUnit, ThatUnit;
implementation
end.
vs
unit Test;
interface
uses
ThisUnit;
implementation
uses
ThatUnit;
end.
Although I welcome the Community editions, I still think that by not including Linux support in the community and…

Although I welcome the Community editions, I still think that by not including Linux support in the community and pro editions, EMBT is making a major mistake. Imagine the activity we could have had when it comes to adding Linux libs and tooling from an enthusiastic community!
/sigh
You must be logged in to post a comment.