Jump to content

Stefan Glienke

Members
  • Content Count

    1428
  • Joined

  • Last visited

  • Days Won

    141

Everything posted by Stefan Glienke

  1. Stefan Glienke

    DelphiLint v1.0.0 released!

    Is it still not possible to create self-contained executables with Java? If so it would be nice because that would remove the requirement for the JRE.
  2. Stefan Glienke

    Variable not initialized?

    https://docwiki.embarcadero.com/Libraries/Athens/en/System.SysUtils.TStringHelper.TrimLeft
  3. Stefan Glienke

    Anonymous methods as interfaces

    Yes you can, the first post in this thread contains the code doing exactly that. In fact, until some version a few years ago it was possible to call Invoke. Still, if the method reference type has {$M+} enabled you can get RTTI for its Invoke method and dynamically invoke it. And there are more than one (Spring) libraries that do that. Also please let's get the terminology right - this is something that hugely annoys the heck out of me - because when talking about this subject everything is being called anonymous method but is incorrect. TProc = refererence to procedure; This is a method reference type - yes, even the official documentation is a mishmash. There is nothing anonymous about this type - it has a name: TProc. procedure Foo; begin end; var p: TProc; begin p := Foo; end. Again there is no anonymous method in this code - the variable p of the method reference type TProc is being assigned. The variable has a name and thus also is not anonymous. var p: TProc; begin p := procedure begin end; end. Now we have an anonymous method - the code block assigned to p has no name. This is an anonymous method that is assigned to the method reference variable p. Also see: https://en.wikipedia.org/wiki/Closure_(computer_programming)#Anonymous_functions https://en.wikipedia.org/wiki/Anonymous_function
  4. Stefan Glienke

    Anonymous methods as interfaces

    As someone using this "feature", I can tell you that the moment they break it I will pester them with issue reports until they revert this "fix". There has been another hidden "feature" in the past: adding operator overloads to records via helper when they are named in a particular way - since a few Delphi versions you can do that natively by declaring operator overloads on record helpers without this "hack" - but the hack still works. Since there is no official language specification and it's basically "if it compiles, it's valid code" I assume this to be added to the documentation rather than to be changed. Embarcadero has not changed things that are worse for backward compatibility reasons in the past so I assume they won't touch this either. The more important thing they should address with anonymous methods is this: not allocating any heap memory when no capturing is happening. The code would look similar to that for the comparers for intrinsic types in System.Generics.Defaults.pas
  5. Stefan Glienke

    How to quickly hash growing files

    SHA1 is dead. I suggest using SHA2 or SHA3 even if it is "just" for a file checksum. If you want performance-optimized implementations I would suggest using mormot2. uses mormot.core.buffers, mormot.crypt.secure; ... HashFile(myFileName, THashAlgo.hfSHA256); Fun fact: mormot2 SHA256 is faster than RTL SHA1.
  6. Stefan Glienke

    RTTI Context can't find an interface

    Nice, never heard of it before but I enjoy looking at libraries that have Spring as their dependency I submitted some improvement suggestions in the area we discussed here.
  7. Stefan Glienke

    RTTI Context can't find an interface

    It is because the compiler does not keep typeinfo of types that are only used as generic parameters in generic types in the public typeinfo list (which is what FindType with a qualified name iterates). If you had included the code for that Unmarshal I could probably give more advice on how to implement it best given that you seem to have support for spring collections in there
  8. Stefan Glienke

    Delphi and "Use only memory safe languages"

    This would be called Tracing garbage collection. But as Dalija already explained the crux is not which way of automatic memory reclamation is being used but the fact that it would be a mix of different ones that don't play together nicely.
  9. Stefan Glienke

    RTTI Context can't find an interface

    Why look up the type by full-qualified name in the first place? Every spring collection has the ElementType property that returns a PTypeInfo.
  10. Stefan Glienke

    Can LoadResString be done according to language ?

    Yes, it can if you are using resource DLLs - see https://docwiki.embarcadero.com/RADStudio/Athens/en/Localizing_Applications
  11. So assuming that your code scales linearly it will only take 92 days for 1 billion rows
  12. Stefan Glienke

    What new features would you like to see in Delphi 13?

    Looks like nobody ever corrected that statement with the introduction of generics - because then even changes in the implementation section are an interface breaking change. They experienced that themself with the 10.2.2 update where some bug in TArray.Sort<T> was fixed which caused issues so the update was pulled and corrected iirc.
  13. Stefan Glienke

    What new features would you like to see in Delphi 13?

    Niklaus Wirth just turned over in his grave about this proposal.
  14. Stefan Glienke

    Delphi and "Use only memory safe languages"

    With the exception that ARC is one of the worst ways of doing that - here are some reasons.
  15. This is nothing new - it's called Eytzinger Layout.
  16. Stefan Glienke

    What new features would you like to see in Delphi 13?

    I said this before and I say it again - nobody should care how long the compiler churns on producing a release config build. Also: the FE is still written by Embarcadero and I don't know how much time is spent there compared to the LLVM BE and how much of that could be improved by tweaking some settings. Given their usual attitude of "making it barely work" and leaving optimizing for later until everyone and their cat/dog complains and then waiting even a few years longer until tinkering around the edges I can only imagine how well done the FE is. Also, keep in mind that the Windows compilers regressed heavily with all the new language features introduced in the past 15 years and that it was mostly due to the efforts of Andreas Hausladen that we gained back some of that speed in the recent versions while still being way behind what it could be imo. Currently reading through the thread (not done yet but just leaving my thoughts as I go through) and this comment was interesting: Interestingly later someone comments that if you compile a different project it turns around into the opposite - and then there is this statement: This is something I have actually seen with the non-Windows Delphi compilers: when I throw some generic-heavy code at them they take a ridiculous amount of time to compile - and some of the optimizations done by Andreas Hausladen actually resolved around generics. I would not be surprised if such an issue still exists either in the BE or in the LLVM code when generating debug symbols due to all the long full-qualified type names.
  17. Stefan Glienke

    What new features would you like to see in Delphi 13?

    If it at least would produce binaries that are faster than what classic compiler for Windows produces ... But due to their currently super old LLVM version (hopefully they upgrade that once they are done on the C++ side which personally I could not care less about), they apparently had to turn off some important optimization steps which causes the binary produced by the Linux compiler to be approx as good as -O0
  18. The usual reasons for memory leaks that I have seen: - not using interfaces as service types - registered components are not inheriting from TInterfacedObject (or some other properly reference counting implementing class) - in combination with the previous point when using AsSingleton without explicitly stating a value for TRefCounting to tell the container if the class implements ref counting or not - injected dependencies are further passed to and held by other services creating cross or cyclic references (use LeakCheck to better find them than just looking through the huge list that FastMM produces, ideally in a smaller scope, 2GB memleak log sounds a bit huge) You can log some of that information by iterating .Registry.FindAll from the container instance and checking various properties of each TComponentModel such as ComponentType, Services and LifetimeType.
  19. The GetSystemTimes call reminds me of System.Threading.TThreadPool.TThreadPoolMonitor.Execute which calls TThread.GetCPUUsage all the time. See https://quality.embarcadero.com/browse/RSP-43540
  20. Stefan Glienke

    GetIt alternatives

    Regardless of which of the mentioned package managers you will be using - all will be open to supply chain attacks.
  21. If the compiler optimization was worth a penny it would not matter which way the code was written and it would emit the best version regardless and depending on the situation where this function is being called and inlined - however, the compiler optimization is rather terrible so this might be some poor attempt to optimize for a certain situation where storing in two boolean variables creates less or no conditional jumps opposed to the short circuit evaluated combined expression with two comparisons.
  22. Stefan Glienke

    Delphi 12 is available

    While Wine 9.0 just introduced this feature? Doubt
  23. Stefan Glienke

    Delphi 12 is available

    Check your facts, please https://learn.microsoft.com/en-us/deployedge/microsoft-edge-supported-operating-systems#supported-operating-systems-for-microsoft-edge Fun fact: that already is the case (it even only runs on Windows 11 21H2 or later) - see https://apps.microsoft.com/detail/9MSMLRH6LZF3
  24. Stefan Glienke

    Delphi 12 is available

    Get real - extended support for both ended four years ago. The market share of Windows 7 is at around 3% If you want to support ancient operating systems then use ancient Delphi versions. According to you Visual Studio 2022 (Supported Operating Systems) would be just dead
  25. Stefan Glienke

    Upgrade from Spring4d 1.2 to Spring4d 2.0

    Do you mean this? https://bitbucket.org/sglienke/spring4d/wiki/Spring4D 2.0 Releasenotes (I think they are not linked from the readme thus easy to miss - I will fix that shortly)
×