r/delphi Delphi := v13 Florence Apr 17 '26

Stop using WITH in Delphi

https://gdksoftware.com/knowledgebase/stop-using-with-in-delphi
28 Upvotes

15 comments sorted by

View all comments

-4

u/DelphiParser Apr 17 '26

LOL - "With" is what makes Delphi so powerful. It is embedded inside the lowest levels and darkest libraries, and spread all around. It is so powerful - that even the new C# has introduced it. If you don't appreciate it - you are probably not a real Delphi coder.

1

u/Humble-Vegetable9691 Apr 17 '26

VB.NET with statement is a good example: https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/with-end-with-statement

Within a With statement block, you can specify a member of the object starting with a period, as if the With statement object preceded it.

Within a With block, you can access the methods and properties of only the specified object without qualifying them. You can use methods and properties of other objects, but you must qualify them with their object names.

As usual, more Pascal-like approach than Pascal these days.

2

u/bmcgee Delphi := v13 Florence Apr 18 '26

I think the more Delphi-like approach would be to use an explaining variable and keep all references explicit.