-
Content Count
277 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Jacek Laskowski
-
As you know, helpers on the one hand are a neat solution, on the other hand they are only syntactic sugar. They have a lot of restrictions, including the lack of the possibility to add fields, but ... Today, when I was writing a helper I tried something like this: program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; type MyInt = type Int64; MyIntHelper = record helper for MyInt private {$WRITEABLECONST ON} const fInitialized : Boolean = False; {$WRITEABLECONST OFF} protected procedure Initialize(); public function ToString(): string; end; procedure MyIntHelper.Initialize(); begin if not fInitialized then begin Self := 123456; fInitialized := True; end; end; function MyIntHelper.ToString(): string; begin Initialize; Result := IntToStr(self); end; var i : MyInt; begin try Writeln(i.ToString); Readln; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. And it works 😉
-
Yes, of course, I was joking.
-
You destroy my day 😉
-
I have a class that does not have an interface, I register it and its factory in this way: TServiceLog = class; TServiceLogFactory = reference to function() : TServiceLog; Container.RegisterType<TServiceLog, TServiceLog>.PerResolve; Container.RegisterFactory<TServiceLogFactory>; pay attention to the use of PerRersolve, maybe it matters. Then I use this class in many other classes, as a parameter in the constructor, all object creation is done by Spring container: TFrameworkSMTPBus = class(TSMTPBus, IFrameworkBase, ISMTPBus) private fServiceLog: TServiceLog; public constructor Create(const aServiceLog: TServiceLog; const aSMTPClientFactory: TSMTPClientFactory); reintroduce; virtual; end; Are TServiceLog instances automatically released by Spring or should I release manually? It looks like it is released by Spring, but I have one case of memory leak, where after adding fServiceLog.Free leaked disappeared. And that's why I ask how it works underneath.
-
Spring4D and objects life cycle
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
I'm asking about Spring principles/rules. Because many instances of one of the classes are released by Spring and one of them is not released. I could not get to the cause. -
You mean probably Marco Cantu, not Marcu Canto 😉 Often this man speaks about Embarcadero and RAD Studio: https://www.ideracorp.com/leadership/AtanasPopov
-
The question was simple: does RTL have functions to convert a string to JSON? There are two answers: 1. Yes, it's FunctionX function from ModuleY module 2. No, there is no such function And I asked because I did not find it, and I do not like to reinvent a wheel.
-
So... Delphi in the RTL library can't convert text to JSON... Ok.
-
[Firedac] Truncation error on Firebird select query
Jacek Laskowski replied to Jacek Laskowski's topic in Databases
No, @Dmitry Arefiev is still silent. I don't know why... -
Named pipe failure, multithreading and asynchronous I/O
Jacek Laskowski replied to FPiette's topic in Windows API
Are the pipes obsolete and not recommended? -
Named pipe failure, multithreading and asynchronous I/O
Jacek Laskowski replied to FPiette's topic in Windows API
Did testing show any additional problems? Is it possible to safely use the library in production? -
Is there any tool that can scan the project and show unused local variables? I know that the compiler shows it, but it is not very clear in the log filled with various warnings.
-
You can freeze all threads except the debug thread (in Threads window).
- 29 replies
-
- delphi ide
- delphi
-
(and 2 more)
Tagged with:
-
what do you mean? give an example
-
JSON is imho most human friendly 🙂
-
[Firedac] Truncation error on Firebird select query
Jacek Laskowski replied to Jacek Laskowski's topic in Databases
And I have this flag set to True! Why, then, don't truncate the data to the length of the field? -
Delphi compiler need to be opensourced
Jacek Laskowski replied to AlekXL's topic in RTL and Delphi Object Pascal
fredvs is MSElang developer, I think so. -
Class inheritance and hides method
Jacek Laskowski posted a topic in Algorithms, Data Structures and Class Design
I have two classes: TFoo = class procedure Terminate(aNow: Boolean); virtual; end; TBar = class(TFoo) procedure Terminate(); end; procedure TBar.Terminate(); begin inherited Terminate(True); end; but I am getting a warning when compiling: [dcc32 Warning] W1010 Method 'Terminate' hides a virtual method of base type How to correctly declare the Terminate () method? I tried with overload, but it did not help. -
Delphi compiler need to be opensourced
Jacek Laskowski replied to AlekXL's topic in RTL and Delphi Object Pascal
Probably Alek definitely simplifies and exaggerates with ease the entire process of opening and managing sources. However, one thing is certain. Delphi requires quick and bold changes, or else it will drown. -
[Firedac] Truncation error on Firebird select query
Jacek Laskowski replied to Jacek Laskowski's topic in Databases
@Dmitry Arefiev Dmitry, take the floor on this, please. Is it working or not? -
Class inheritance and hides method
Jacek Laskowski replied to Jacek Laskowski's topic in Algorithms, Data Structures and Class Design
Thanks, but what if another class inheriting from TFoo needs to be able to control the parameter from outside? -
Class inheritance and hides method
Jacek Laskowski replied to Jacek Laskowski's topic in Algorithms, Data Structures and Class Design
From the base class, TFoo inherits several different classes, just this one child class TBar should always pass True in this parameter. -
Class inheritance and hides method
Jacek Laskowski replied to Jacek Laskowski's topic in Algorithms, Data Structures and Class Design
I know where a warning message comes from. I ask how to solve it correctly for the Terminate method without parameters. -
Class inheritance and hides method
Jacek Laskowski replied to Jacek Laskowski's topic in Algorithms, Data Structures and Class Design
Of course, override generate other error: [dcc32 Error] E2037 Declaration of 'Terminate' differs from previous declaration -
[Firedac] Truncation error on Firebird select query
Jacek Laskowski replied to Jacek Laskowski's topic in Databases
I checked the Rio, here the problem also exists. But I also found it: https://quality.embarcadero.com/browse/RSP-16057 And now I don't understand anything.