Jump to content

EugeneK

Members
  • Content Count

    65
  • Joined

  • Last visited

Everything posted by EugeneK

  1. In Dalija Prasnikar's smart pointer unit here https://github.com/dalijap/code-delphi-mm/blob/master/Part5/SmartPointer/uSmartPtr.pas#L8 following code is used ISmartPointer<T> = reference to function: T; TSmartPointer<T: class, constructor> = class(TInterfacedObject, ISmartPointer<T>) basically anonymous method declaration is equivalent to interface. Is it documented somewhere? I tried looking at Interfaces and Anonymous method sections in documentation but can't find anything.
  2. EugeneK

    Anonymous methods as interfaces

    I'm not sure you understand my point. What I'm saying is that Embarcadero can theoretically hide ability to implement this interface manually and all existing code that uses anonymous methods in documented way will still work. Or they can change interface, say, rename Invoke to InvokeEx for some reason. So manually implementing this interface is a hack that can randomly stop working. Although I agree that probability is low that they will change it.
  3. EugeneK

    Anonymous methods as interfaces

    I'm not saying doing it without interface, I mean hiding this implementation detail from the users. I.e. not allowing to manually implement this interface in code. This won't break any documented uses of anonymous methods.
  4. EugeneK

    Anonymous methods as interfaces

    But this implementation does not have to be accessible as interface to end user for it to work.
  5. EugeneK

    Anonymous methods as interfaces

    I think anonymous methods will still work without ability to explicitly use them as interfaces. I could not find it being used in this way anywhere in Delphi RTL.
  6. EugeneK

    Anonymous methods as interfaces

    So it is not officially supported and theoretically can be changed?
  7. EugeneK

    Delphi and "Use only memory safe languages"

    I meant in my own code, for example in unit tests sometimes it is easier to provide mock of some class rather than constructing it. It is an outlier but it exists, which means it is possible, and I dread thinking what it would have been using it if it would not be interface based. Well in my case it would have been an innocent bug because it was assigned just after creating, so no information was lost, but application would have been working instead of shutting down every few days. That's really nice, I wonder why they won't add something like this to RTL. But you agree that it is less readable than using interfaces. But why would you want to typecast back to TStrings? By backwards compatible I meant that existing code won't break and if you need to use TStrings you just use continue to use TStrings as before, but in new code if you declare it as IStrings you can pass it to procedures that accept IStrings. Main purpose is separation of interface from implementation so you can use TMySuferfastStrings or TUnitTestThisClassStrings and your code won't need any changes, I guess I prefer way of C# where all collections are interfaced, rather than C++
  8. EugeneK

    Delphi and "Use only memory safe languages"

    Of course you don't just add interface to declaration, some work is needed but all your description does not say that it can't be implemented in backwards compatible way. And doing it class by class is much easier than adding ARC to whole compiler. All classes that take TComponent owner already need to be manually freed when passed nil as a parameter. There could be bugs because of double free/memory leak because of this too. Exactly! That's the whole point, it also has other advantages, like ability to provide different implementation for classes. And TComponent seems to already implement interface reference counting, so maybe all that is needed to add interface implementing public methods. You never really need automatically manage memory, you can always free it manually it just a big source of bugs. I think goal of compiler developers should be to give people options to avoid them and write simpler code. Just now I found 10 year old bug where TStrings object was assigned to already created object causing memory leak, this kind of bug is almost impossible to find and it would not be a problem if it was IStrings instead. For smart pointers I don't really see a way to use them as elegantly as interfaces, at least with current Delphi language. I don't agree with this, but Embarcadero devs seem to agree, since they closed my ticket about it.
  9. EugeneK

    Delphi and "Use only memory safe languages"

    I was thinking something like TXmlDocument/IXmlDocument, if you use TXmlDocument you continue using regular Create/Free or component ownership and if you use IXmlDocument it is reference counted.
  10. EugeneK

    Delphi and "Use only memory safe languages"

    I wish they added interfaces to existing RTL classes, this would be nice backwards compatible way to improve memory management.
  11. You can take a different approach, these fields are reflecting some query, since you declare all the fields I assume query is static. This means that you can generate Delphi code based on this query, that will declare and assign all the variables, so you won't have to write it yourself and in addition this will make it easy to add new queries, and if you change query compiler will tell you about errors in dependent code.
  12. Hi I noticed that in THttpCli 404 StatusCode is returned in many different situations like timeout/DNS resolution failure, which makes it difficult to diagnose issues because it is the same as legitimate 404 code from web server. Is it possible to change it to something else?
  13. Was anyone able to install EurekaLog 7.12.0.4? For me it crashes after login/password screen. 7.12.0.3 is ok.
  14. EugeneK

    Duration as string ?

    If you are on Windows you can check GetDurationFormatEx in Winapi
  15. Hi Anyone else has this issue? It happens when I start debugging. Is it worth create a ticket for Embarcadero? Do they work with antivirus companies to prevent it?
  16. EugeneK

    Crowdstrike antivirus killing Delphi

    It is challenging when you are in a big organization you need to work with IT team, Security team, get approval from management etc. and then repeat it for each new version. I wish Embarcadero worked with antivirus providers to whitelist it permanently.
  17. I always declare it inside the loop if it is not used outside. Declaring it outside may lead to hard to find bugs.
  18. EugeneK

    ICS V9.0 announced

    Yes I figured it out, looks like my work firewall or antivirus blocks it.
  19. EugeneK

    ICS V9.0 announced

    Site seems to be down right now.
  20. Hi Anyone else has internal errors after upgrading? I've got 2 so far https://quality.embarcadero.com/browse/RSP-43437 https://quality.embarcadero.com/browse/RSP-43435 really disappointing that quality degrades, especially when it is so easy to avoid by letting more people in the beta program. Don't understand why Embarcadero is shooting itself in the foot like this.
  21. EugeneK

    Delphi 12 internal errors

    I was not aware of it, the only post I've seen is this one https://blogs.embarcadero.com/delphi-supports-android-api-33-via-yukon-beta/ in comments they say it only goes to selection of customers based on certain criteria.
  22. EugeneK

    Delphi 12 internal errors

    It was only for "premium" subscription, there was whole thread about it
  23. Hi There is following code in the end of TCustomSslWSocket.TriggerSSLHandshakeDone Disconnect := FALSE; if Assigned(FOnSslHandshakeDone) then FOnSslHandshakeDone(Self, ErrCode, FSslPeerCert, Disconnect); if Disconnect and (ErrCode = 0) then Close; I wonder why last two lines not just if Disconnect then Close; User can't force disconnect on failed handshake?
  24. EugeneK

    Rad 12 Beta - Link to News

    Another blog about changes https://blog.marcocantu.com/blog/2023-october-nativeint-weak-alias.html
  25. EugeneK

    Component color in design time

    Hi Say I have following simple component, in runtime it shows it as blue, but in design time in has default color, how to fix it? unit UTestPanel; interface uses System.Classes, Vcl.Controls, Vcl.ExtCtrls; type TBluePanel = class(TPanel) strict private FPanel: TPanel; public constructor Create(AOwner: TComponent); override; end; procedure Register; implementation uses System.UITypes, Vcl.Forms; constructor TBluePanel.Create(AOwner: TComponent); begin inherited; FPanel := TPanel.Create(Self); FPanel.Parent := Self; FPanel.Align := alClient; FPanel.ParentBackground := False; FPanel.ParentColor := False; FPanel.Color := TColors.Blue; end; procedure Register; begin RegisterComponents('TestObjects', [TBluePanel]); end; end.
×