Jump to content

Jacek Laskowski

Members
  • Content Count

    277
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Jacek Laskowski

  1. Jacek Laskowski

    Helper trick ;-)

    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 😉
  2. Jacek Laskowski

    Helper trick ;-)

    Yes, of course, I was joking.
  3. Jacek Laskowski

    Helper trick ;-)

    You destroy my day 😉
  4. 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.
  5. Jacek Laskowski

    Spring4D and objects life cycle

    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.
  6. Jacek Laskowski

    Make attention to Embarcadero

    You mean probably Marco Cantu, not Marcu Canto 😉 Often this man speaks about Embarcadero and RAD Studio: https://www.ideracorp.com/leadership/AtanasPopov
  7. Jacek Laskowski

    JSON string value

    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.
  8. Jacek Laskowski

    JSON string value

    So... Delphi in the RTL library can't convert text to JSON... Ok.
  9. Jacek Laskowski

    [Firedac] Truncation error on Firebird select query

    No, @Dmitry Arefiev is still silent. I don't know why...
  10. Jacek Laskowski

    Named pipe failure, multithreading and asynchronous I/O

    Are the pipes obsolete and not recommended?
  11. Jacek Laskowski

    Named pipe failure, multithreading and asynchronous I/O

    Did testing show any additional problems? Is it possible to safely use the library in production?
  12. Jacek Laskowski

    Unused local variables

    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.
  13. Jacek Laskowski

    Forked VSCode for Delphi

    You can freeze all threads except the debug thread (in Threads window).
  14. Jacek Laskowski

    How to clone settings ?

    what do you mean? give an example
  15. Jacek Laskowski

    How to clone settings ?

    JSON is imho most human friendly 🙂
  16. Jacek Laskowski

    [Firedac] Truncation error on Firebird select query

    And I have this flag set to True! Why, then, don't truncate the data to the length of the field?
  17. Jacek Laskowski

    Delphi compiler need to be opensourced

    fredvs is MSElang developer, I think so.
  18. 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.
  19. Jacek Laskowski

    Delphi compiler need to be opensourced

    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.
  20. Jacek Laskowski

    [Firedac] Truncation error on Firebird select query

    @Dmitry Arefiev Dmitry, take the floor on this, please. Is it working or not?
  21. Jacek Laskowski

    Class inheritance and hides method

    Thanks, but what if another class inheriting from TFoo needs to be able to control the parameter from outside?
  22. Jacek Laskowski

    Class inheritance and hides method

    From the base class, TFoo inherits several different classes, just this one child class TBar should always pass True in this parameter.
  23. Jacek Laskowski

    Class inheritance and hides method

    I know where a warning message comes from. I ask how to solve it correctly for the Terminate method without parameters.
  24. Jacek Laskowski

    Class inheritance and hides method

    Of course, override generate other error: [dcc32 Error] E2037 Declaration of 'Terminate' differs from previous declaration
  25. Jacek Laskowski

    [Firedac] Truncation error on Firebird select query

    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.
×