Jump to content

Stefan Glienke

  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Stefan Glienke

  1. Stefan Glienke

    Waiting for Sydney

    Left to right: Denver, Rio, Nairobi, Tokio, Berlin, Moskau, Helsinki, Oslo
  2. Stefan Glienke

    language updates in 10.4?

    That is only an issue for library authors that need to target a range of past versions which is the vast minority of Delphi users. Most migrate to a new version, start using that and never have to run their code through previous versions. Type inference for inline variables is a really nice thing - no need to explicitly decare the type just to tell the compiler (yes, if you name your variable properly the type is irrelevant for understanding the code, ask programmers from other languages that have this feature for a long time). Also often enough you have to add units to a uses clause just to declare a variable of a type that is the return of a method of some other type being used - with type inference that becomes unnecessary.
  3. I don't understand the original problem - please describe exactly the data in a complete but small enough sample and the way you want it to be organized/shown.
  4. Stefan Glienke

    Fonts & ligatures

    As far as I know the editor control does not support ligatures
  5. FWIW I have done similar but in many cases just looking at the disassembly does not tell the entire story - running the code and profiling it (which can be a very tedious process given the many different uses cases etc) will often tell a different story and modern hardware architecture just shows you the middle finger. Especially for routines that get inlined in many different places although they might produce a little bit better disassembly it might not be worse or even better in some cases to not inline them if they can be written jump free because the code will be smaller and likeliness of staying in the instruction cache will be higher. But again we are talking about microoptimization here that requires a lot of profiling and looking at some cpu metrics.
  6. I don't know about the particular piece of code but I absolutely second that - if you can avoid branching, please please do so - unfortunately neat and clean code (an innocent looking if or a loop) can easily turn into a performance drain.
  7. Some of the benchmark results are just eyewash fwiw
  8. Stefan Glienke

    RTTI info for TBytes using runtime packages

    Regardless the current typeinfo issue I would always check for typeKind = tkDynArray (and possibly even tkArray) and ElemType = Byte because then you can also handle any custom declared TMyBytes = array of Byte type.
  9. Stefan Glienke

    RTTI info for TBytes using runtime packages

    The types are assignment compatible. When you declare a variable of TBytes in one module and call a method from a runtime package that uses TBytes that code will compile and work. Just the typeinfo generated is different so if you do some RTTI work you get false results.
  10. Stefan Glienke

    RTTI info for TBytes using runtime packages

    The issue is that TBytes is an alias for TArray<Byte> - generic types being used across different modules have several implications such as that they manifest into each module with their own typeinfo being generated. Try this code for example: uses Rtti, SysUtils; var ctx: TRttiContext; begin Writeln(ctx.GetType(TypeInfo(TBytes)).QualifiedName); end. In a regular console application it will print: System.TArray<System.Byte> While you would assume that it should print: System.SysUtils.TBytes Now if you enable runtime packages for this console application and let it link with rtl you will get an ENonPublicType here. Every module that is using TBytes is not referencing some type that is declared in the RTL runtime package but emiting its own version of TArray<Byte> into its binary. Personally I think this is an issue with the compiler treating the declaration of TBytes = TArray<Byte> different from TBytes = array of Byte in terms of the typeinfo generated - I was sure there is a QP entry somewhere about it but I cannot find it right now. To further provide the proof that aforementioned assumptions of other posters are wrong use the following code with a console application linking with the rtl package: uses Rtti, TypInfo, Classes, SysUtils; var ctx: TRttiContext; begin Writeln(ctx.GetType(TBytesStream).GetField('FBytes').FieldType.Handle = TypeInfo(TBytes)); end. This will print FALSE as the typeinfo of the FBytes field which is of type System.SysUtils.TBytes in fact differs from the typeinfo generated for the usage of TBytes in the console application binary. In fact there does not even exist a type called TBytes but only System.TArray<System.Byte> as TBytes it just an alias as I said and the declaration TBytes = type TArray<Byte> is not legit and raises E2574 Instantiated type can not be used for TYPE'd type declaration
  11. Stefan Glienke

    Difference between Pred and -1

    Fun fact: you can omit the 3rd argument of Copy if you just want to cut from the beginning.
  12. Stefan Glienke

    Find record operators via Rtti?

  13. Stefan Glienke

    Exception.CreateFmt vs. CreateResFmt

    It gets bad if the implicit string or other managed type variables are the only of that type because then you get the implicit try finally added. And at least for win32 we know now that try/finally is implemented kinda badly: https://quality.embarcadero.com/browse/RSP-27375
  14. Stefan Glienke

    Exception.CreateFmt vs. CreateResFmt

    That is why for performance critical code such code should be moved to an extra (or nested) routine. Otherwise you get pro- and epilogue polluted with code that is not necessary in the majority of cases. Additional read: https://www.delphitools.info/2009/05/06/code-optimization-go-for-the-jugular/
  15. Stefan Glienke

    Setting a "nullable" property on a .NET object

    Yes it is, it's a struct
  16. Stefan Glienke

    Overstatic methods

  17. Stefan Glienke

    Generic class

    Generics in Delphi have more severe issues that should be worked on than that tbf
  18. Stefan Glienke

    spring4d list immidiately gets freed

    FToollist is certainly not being freed but the items because the list returned by FindAll has OwnsObjects = True and goes out of scope at the end of the method. Write dm.Session.FindAll<TTool>.MoveTo(FToolllist);
  19. Stefan Glienke

    language updates in 10.4?

    I would like to but I don't (and not because of FUD but because I know of the bugs myself) - do I need to say anything more? Ask around in other languages if people in general trust their compilers and standard runtime libraries or not.
  20. Stefan Glienke

    language updates in 10.4?

  21. Stefan Glienke

    Generics and Classes on Windows 2000 = OOM

    Dynamic arrays cannot leak unless you circumvent the compiler generated code controlling their reference counting.
  22. Stefan Glienke

    Generic class

    FWIW just recently my coworker opened these issues that are related to this topic: https://quality.embarcadero.com/browse/RSP-27799 https://quality.embarcadero.com/browse/RSP-27802
  23. Stefan Glienke

    language updates in 10.4?

    VS is also not perfect but their compiler and language design is rock solid - yes, if you look into C# communties there are also people complaining that stuff is not C#-ish and that but the number of times where the C# compiler just craps itself, kills the entire IDE or simply produces completely wrong code is like several orders of magnitudes less than with Delphi.
  24. Stefan Glienke

    language updates in 10.4?

    YES, exactly that! However many Delphi developers have a troubled past where often "new" things turned out to be broken, caused problems or were simply not thought through entirely and just slapped onto existing things like duck tape. Like using attributes like [ref] in addition to the existing keyword const just because of the fear to introduce new keywords or introducing inline variables (that had many bugs) without the entire tooling understanding them and stopping to work. So many people are in the mindset of "don't touch it so you can't break it" and "fix the existing bugs before adding new broken stuff"
  25. Stefan Glienke

    language updates in 10.4?

    Interesting - even with {$mode delphi} it does not allow that - probably it's yet another of those bazillion switches of FPC to make it behave similar to Delphi - not that I would ever care. Anyhow this is still a thread about Delphi so your approach is not sufficient here imo. @Fr0sT.Brutal It's a little less simplistic than that but basically yes.