Jump to content

Dalija Prasnikar

Members
  • Content Count

    562
  • Joined

  • Last visited

  • Days Won

    52

Everything posted by Dalija Prasnikar

  1. Use Supports function var LTheme: ITheme; begin if Supports(Obj, ITheme, LTheme) then LTheme.UpdateTheme; end;
  2. Dalija Prasnikar

    RAD Studio 11 Alexandria is now available

    We have no idea. New roadmap hasn't been published yet.
  3. No. Because you need type for as operator. (intf_1 as IMyInterface).C; But you also need to add GUID to your interface declaration because without it it cannot be identified.
  4. Dalija Prasnikar

    Delphi 11 first look issues

    Try changing more settings. At some point they will be persisted. Another option is to import 10.4.2 settings or change problematic options directly in registry, before you start IDE
  5. Dalija Prasnikar

    Delphi 11 first look issues

    This sounds like same issue: [REGRESSION] Editor Font setting is not persisted. https://quality.embarcadero.com/browse/RSP-34854
  6. Dalija Prasnikar

    RAD Studio 11 Alexandria is now available

    No, because there are none.
  7. Dalija Prasnikar

    RAD Studio 11 Alexandria is now available

    Borland is dead.
  8. Dalija Prasnikar

    RAD Studio 11 Alexandria is now available

    Africa, Egypt. There was the largest library in ancient world.
  9. Not really. https://jlericson.com/2021/08/24/git_rewrite_1.html https://jlericson.com/2021/09/06/git_rewrite_2.html
  10. Yes. Usually in separate repository, but sometimes in the same as the project which is using them. Anything I can lay my hands on... my book manuscripts, documentation, illustrations and images, 3rd party source code, my own source code or all kinds, recipes, to do lists, basically all kinds of documents that can (or cannot) change with time.
  11. Yes, it can. But the problem is not in hiding your constructor. Every class in Delphi descends from base TObject class, whether you explicitly state that in class declaration or not TSingleton = class TSingleton = class(TObject) And TObject has public constructor Create. That means its every descendant and consequently every other class in Delphi has public constructor Create. Since it is public it is accessible and you cannot prevent people using it. So, even if you hide constructor in descendant class, someone can write TSingleton.Create and this will not call your hidden constructor, but TObject default constructor. The only way to hide that TObject constructor is to add public constructor with same name in your class, like in example I posted. But then you again have problem with having publicly accessible constructor and people can instantiate more than single object instance. If that public constructor raises exception, then at least code will fail at runtime showing that this constructor shouldn't be used.
  12. There is another way to prevent instance creation - or at least misuse - having public constructor that raises exception. TSingleton = class private class var FInstance: TSingleton; constructor CreateSingleton; class destructor ClassDestroy; public constructor Create; class function Instance: TSingleton; static; end; class destructor TSingleton.ClassDestroy; begin FInstance.Free; end; constructor TSingleton.Create; begin raise Exception.Create('Singleton instance cannot be directly constructed'); end; constructor TSingleton.CreateSingleton; begin // actual constructor end; class function TSingleton.Instance: TSingleton; begin if not Assigned(FInstance) then FInstance := TSingleton.CreateSingleton; Result := FInstance; end;
  13. You cannot make such singleton in Delphi. Public TObject constructor will be always visible and you cannot hide it, The only way to disable access to the constructor is to define singleton API as interface and have public factory method that returns interface, and then put class implementation inside implementation section of the unit making it inaccessible to the outside world.
  14. Dalija Prasnikar

    thread-safe ways to call REST APIs in parallel

    Creating separate objects would be my preferred approach, they are not that heavy to have significant impact on performance. ExecuteAsync is .... I have no words for describing it... maybe some people would like it, but for me it is useless addition. If you want to run rest it in the background thread simplest code is to just run the whole thing in background thread and then synchronize only if you need to synchronize some piece of code. With Execute you get clean code under your control where it is obvious what runs where and how you need to handle things, with ExecuteAsync you first need to learn how to use it properly. I would forget about it as it does not offer any advantages. I am glad if it helped to give you some insight, because I was confused about what you are aiming at. You can ask only very specific questions on Stack Overflow. For instance your initial question here would be definitely off topic on Stack Overflow. If you can create some minimal code example something in line what I have posted here as example, then you can aske whether you are doing it correctly and whether it is thread safe. It is also good to point to specific parts of the code you are not sure about. When it comes to thread safety it depends on the actual code and sometimes people don't add enough code. On the other hand adding too much code is also a problem because it is harder to get clear picture id there is plenty of code. For instance, if you need to populate UI, you don't need to show 50+ lines of UI related code. One is enough. The quality of answers also very much depends on the quality of the question. If answering requires a lot of guessing you will less likely get good answers. Few lines of code speak better than words 🙂 Don't describe your code, write it - even if it is just a rough concept. Then build the rest of the explanation on top of that.
  15. Dalija Prasnikar

    thread-safe ways to call REST APIs in parallel

    I don't understand what is your problem. You asked whether those classes are safe, we answered they are not. Every thread needs to have dedicated object instance for each one - client, request, response. Even if you use ExecuteAsync, you cannot share that instance. So basic example would be for i := 0 to Data.Count-1 do begin RunRest(Data[i]); end; procedure RunRest(const s: string); begin TTask.Run( procedure var Client, Response, Request... begin Client := TRESTClient.Create(s); try Response := TRESTResponse.Create(Client); Request := TRESTRequest.Create(Client); // other rest setup... Request.Execute; // process Response, if needed you can do that in Synchronize call - if you are interacting with GUI then you definitely need to Synchronize here finally Client.Free; end; end); end;
  16. Dalija Prasnikar

    Konopka VCL Controls not included in GetIt in delphi community latest edition

    Konopka VCL Controls are not available for Community Edition. You need to have purchased license (see under Subscription) to get them: https://getitnow.embarcadero.com/KonopkaControls-270-6.2.3/
  17. TFunc is anonymous method, which are backed by interface. So GUID you get from field type is not for ITestA,, but for TFunc<ITestA>. I don't think you can get generic part out from parameterized type. In theory TFunc has Invoke method, so if you could get information on its result type, you would have ITestA. But I couldn't get Invoke information out of RTTI. The real question here is what you are actually trying to do. Your test code is obviously just a test - you already know that TForm1 MyField works with ITestA, so if you can make small test case for your actual use case, maybe there is a way to get information you need. For instance if your form would be generic, you would more easily get what you need because you would have T to work with TForm1<T> = class(TForm) private MyField:TFunc<T>; end;
  18. Dalija Prasnikar

    thread-safe ways to call REST APIs in parallel

    None of those components are not thread-safe. They can be used in background threads, but each thread needs to have their own instances. Yes, you need separate client objects for each thread, too. If the StringList is not shared and you generating unique file name is coordinated between threads, so there cannot be any overlap, then it is safe to save inside thread.
  19. Dalija Prasnikar

    10.4.1+ Custom Managed Records usable?

    Right... I completely misinterpreted what you were saying. I guess it is "I am reading words, but their meaning is not arriving in my brain" day...
  20. Dalija Prasnikar

    10.4.1+ Custom Managed Records usable?

    I think it is called ternary because there are three expressions in play.
  21. Dalija Prasnikar

    upcoming language enhancements?

    If anyone is interested in upcoming version, there will be a webinar https://register.gotowebinar.com/register/4959183786599768588
  22. Dalija Prasnikar

    10.4.1+ Custom Managed Records usable?

    I always had high hopes that by 10.7 everything will work as intended. Now we will have to wait until Delphi 17.
  23. Dalija Prasnikar

    10.4.1+ Custom Managed Records usable?

    I have seen plenty of developers (not only Delphi) jumping on new features and rewriting code for no good reason. It never hurts explicitly stating even the obvious things
  24. I keep asking myself the same question over and over again. Let me know if you find the answer 😕
  25. I am working on one, but it is work in progress. Intention is to make this during follow up series of blogposts. Since I am quite busy at the moment, I am not sure when will this see the light of day. I already have such framework written in Swift, so most of the mental work is finished, but there is still a lot to do beyond merely translating it to Delphi, as it does not have all bells and whistles fully in place.
×