Jump to content

pyscripter

Members
  • Content Count

    1069
  • Joined

  • Last visited

  • Days Won

    70

Posts posted by pyscripter


  1. The following correctly produces the same hint, whilst in some earlier Delphi versions it wrongly produced a hint if the offending statement was omitted.

    function Test(Value: Integer): Integer;
    begin
      Result := -1;
      if Value > 0 then
        Result := 0
      else
        Abort;
    end;

     


  2. Actually I am getting the hint with both Win32/Win64  (32 bit IDE) and a DEBUG configuration that looks like a release configuration. 

     

    image.png.a8173dab575e53b40f07cf976f351a02.png

     

    The funny thing is that if I remove the offending line and disable assertions, then I get a warning about the undefined result!  You can't win.


  3. The following gives a hint in D13: H2077 Value assigned to Test never used:

    function Test(Value: Integer): Integer;
    begin
      Result := -1;
      if Value > 0 then
        Result := 0
      else
        Assert(False);
    end;

    Is the hint justified?  What if Assertions are turned off?  Note that in earlier versions you would get a warning if you omit the first line.


  4. As per title.  The MultiInstaller in the Install subdirectory has also been updated and now installs P4D in both the 32-bit and 64-bit IDEs.   It is the fastest way to install P4D.  Just clone the repo and run MultiInstaller.  It only takes a few seconds to install in both IDEs and configure the search paths.  The provided setup.ini expects the folder to be called P4D.  If not, you need to edit the setup.ini file accordingly. The only catch is that in the dialog box you should specify the parent folder of "P4D" (i.e. the folder containing the directory to which you have copied/cloned P4D) and not the P4D folder itself. 

    • Like 1

  5. There have been some significant improvements to TJSONSerializer.  The following have been added:

      TJsonValueSerialization = (Always, ExcludeDefault, ExcludeSpecial, ExcludeAll);

      TJsonReferenceHandling = (None, Preserve, IgnoreCycles, ErrorOnCycles);

     

    Also the following related issues I had submitted have been fixed.

    In addition the a couple of my older issues have been addressed:

    Note that, for some reason, the list of issues fixed in New features and customer reported issues fixed in RAD Studio 13.0 - RAD Studio does not include some of the above fixed issues.   So the list does not appear to be comprehensive.

    • Like 3

  6. 6 minutes ago, Vincent Parrett said:

    but I have a requirement to work with XE2+ and the system.json unit has various bugs

    I understand.  Json serialization (System.JSON.Serializer) became reliable only with Delphi 11 and later.  I think it was introduced in Delphi 10.4.


  7. 1 hour ago, Stefan Glienke said:

    InsertRange and DeleteRange, as you describe them, are not possible without changing the existing TStringList behavior regarding OnChanging/OnChange - currently, if you insert or remove several items in a loop using Insert or Delete, on every OnChanging/OnChange call, the TStringList has the exact Count and Items before/after that one insertion/deletion. With a bulk insert or deletion, that would not be the case

    This is not quite true. TStrings does not define Insert/DeleteStrings but it has an AddStrings function.   This function is inefficient (adds the strings one-by-one), but the operation is enclosed in Begin/EndUpdate, so you only get change notifications before and after the whole operation.  In an analogous way, an InsertStrings function would/should only notify before and after the whole operation.   There is no need/requirement for calling Changing/Changed per item.

     

    @Dave Novo  It is indeed easy to write a TStringList class helper that adds efficient implementations of Insert/DeleteStrings.  You can get access to the private  variable FList using the well known "with Self" trick as @Anders Melander pointed out earlier. It is worth noting, that, unfortunately, these functions cannot be implemented efficiently at the TStrings level.

     

    The underlying data structure of SynEdit is a TStrings descendent.  Whether that is a good choice is debatable, but It does define such functions (InsertStrings, DeleteLines) and implements efficiently with a single Move, so you could have a look at SynEdit/Source/SynEditTextBuffer.pas at master · pyscripter/SynEdit to get ideas about how to implement them for TStringList.

     

    It is worth creating an enhancement request to the Delphi issue tracker, asking for such functions to be added.  Insert/DeleteStrings could be declared as virtual in TStrings with inefficient implementations and then implemented efficiently in descendent classes. Also, the following procedure

    procedure AddStrings(const Strings: array of string); overload;

    should be declared virtual and implemented efficient in descendent classes.


  8. 4 hours ago, FoxWMulder said:

    It's strange that Delphi still doesn't have a proper multicursor. Like in SublimeText. Ctrl+Shift+J and Cltr+R are not always convenient.

    Indeed, but this is just one of the many IDE Editor limitations:
     

     


  9. 18 minutes ago, PeterPanettone said:

    IMO, converting even a very large sequence of strings to a collision-free hash table at compile-time using a dictionary would be the most efficient way.

    And writing everything in assembly may save you a few miliseconds....:classic_biggrin:

    This is not about efficiency, but about writing better and more readable code.  It is the compiler's job to convert source code to the most efficient machine code. 


  10. The variable HW is defined in the main interpreter and is not available in the newly created sub-interpreter, which is isolated from the main interpreter.  Hence the error.

     

    PS: I wonder why everyone is so obsessed with running python in threads, especially GIL owning ones.  This is quite an advanced feature and requires deep understanding of the topic.   P4D makes it easy to use this feature, but this does not mean that users do not need to study the python documentation and understand the nuances.  To use an analogy, Delphi encapsulates threads pretty well but doing thread programming in Delphi is not trivial and requires understanding the pitfalls.


  11. 10 hours ago, Anders Melander said:

    ...unless you also monitor the parent directory.

    You will still have the same issue if the parent directory (or the parent of the parent...) gets deleted or renamed.  Even if not,  you may be getting many more notifications than you need.  Also you would have to watch subfolders, which you may not want. 

     

    It is not worth it. Checking every x seconds whether the monitored directories still exist, is a tiny overhead.

×