Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

3 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I guess the real reason, why Delphi represents components in packages as string names (as opposed to direct TClass references) is because a package can stay in non-loaded state. Look at IOTAPackageInfo.Loaded property.
  2. Collections as records seems to me a good idea. I've thinked about creation of such a library for a long time. However, my goals was to achieve as light solution as possible. For example, every TList instance currently - are several heap memory blocks. Two objects and a block of memory for items. Every object in Delphi have implicit try/except in its constructor, and so on.... So, Tlist is quite more complicated compare to native dynamic arrays (which seems to me much more optimal). Also, I think value sematics of record types should be supported. So, when A and B are collections, user can assign one to another, like A := B. And here something like copy-on-write should be provided. For this either: Delphi 10.4 managed records feature can be used, or, collection types should have single interface field (IInterface or similar), and all requited additional data fields (like Count, Capacity, ect. fields) should be incapsulated into it. This complicate things to some degree. Also, this way (with a single interface field inside) collections, implemented as record types, wil be able to auto-initialize and auto-free itself, which will simplify user's code.
  3. My vote is for this way: On the orther hand, collections are different from arrays in the following aspect: colections are typically used in much wider scopes (like in public APIs) than arrays (which are mostly used quite locally).
  4. balabuev

    fun coding challenge

    I think you misunderstood the initial task...
  5. balabuev

    fun coding challenge

    Everything works ok. You have to use Math and StrUtils units.
  6. balabuev

    fun coding challenge

    procedure CombineMemos(const AMemos: array of TMemo; ADelimiter: Char; AResult: TMemo); var i, cnt: Integer; rem: UInt64; idx: UInt64; mm: TMemo; s: string; begin cnt := Ord(Length(AMemos) > 0); for mm in AMemos do cnt := cnt * mm.Lines.Count; for i := 0 to cnt - 1 do begin s := ''; rem := i; for mm in AMemos do begin DivMod(rem, mm.Lines.Count, rem, idx); s := s + IfThen(mm <> AMemos[0], ADelimiter, '') + mm.Lines[idx]; end; AResult.Lines.Add(s); end; end;