Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 10/15/20 in all areas

  1. This surprised me a lot, and I believe (hope!) is a very good sign: "Recently we launched a new experiment of opening up some internal projects for MVPs to work on. As opposed to some of our open-source initiatives like Bold, these are still owned by Embarcadero and a primary part of the product." https://blogs.embarcadero.com/update-xml-mapper/
  2. Kryvich

    Organizing enums

    I have several open-source projects, old and new, but there is no active use of enumerations. But they are actively used in my amateur projects related to linguistics and others. To give a hint of how the enumerations can be used, take for example the syntactic analyzer messages, warnings and errors: TSyntaxMessage = (smNone, // Here are suggestions of syntax analyzer: smRareLinkForWord, // Rare syntactic link smFirstSuggestion = smRareLinkForWord, smAdjToVerb, //... smSuggestionN, smLastSuggestion = smSuggestionN, // Here are warnings smNotLinkedWord, smFirstWarning = smNotLinkedWord, // ... smWarningN, smLastWarning = smWarningN // Here are errors ); We have a list of messages logically divided into groups: 1) no message smNone, 2) suggestions smFirstSuggestion..smLastSuggestion, 3) warnings smFirstWarning..smLastWarning, 4)... I don't need to set numerical values of members and check if they fall into the required sub-ranges. This happens automatically. Now I can write: case SyntaxMessage of smNone: ; // All is OK smFirstSuggestion..smLastSuggestion: ProcessSuggestion; smFirstWarning..smLastWarning: ProcessWarning; else Assert(False, 'Ops...'); end; We can create a helper to work with messages: TSyntaxMessageHelper = record helper for TSyntaxMessage class function FromString(S: string): TSyntaxMessageHelper; static; // Returns TSyntaxMessage by the name function ToString: string; // Returns the name of message function Text: string; // Get a text of user's message end; And use this as follows: Mess1 := TSyntaxMessage.FromString('smBadUseOfVerb'); // when loading from XML etc. s := Mess1.ToString; // when saving to XML, JSON,... ShowMessage(Mess1.Text); Then we can declare a set of messages, add a helper for it, and work in a convenient manner. TSyntaxMessages = set of TSyntaxMessage; TSyntaxMessagesHelper = record helper for TSyntaxMessages class function FromString(S: string): TSyntaxMessages; static; function ToString: string; function Text: string; function First: TSyntaxMessage; function IsEmpty: Boolean; function Count: Integer; procedure ExcludeWarnings; procedure Include(const Messages: TSyntaxMessages); procedure Exclude(const Messages: TSyntaxMessages); procedure ForEach(Proc: TSomeProcedure); //... end; MyMessages := TSyntaxMessages.FromString('smRareLinkForWord smAdjToVerb smNotLinkedWord'); if not MyMessages.IsEmpty then Mess := MyMessages.First; MyMessages.Include(OtherMessages); MyMessages.ForEach(DoSomething); We can add inline to the method declarations for faster code. A variable of type TSyntaxMessages will have a minimum size sufficient to store the set. The compiler will automatically check for ranges.
  3. Remy Lebeau

    Delphi 10.4.1 and the IDE FIx Pack

    Yup, and here we are, months after the initial 10.4 release, and already into a new 10.4.1 release, and Embarcadero still hasn't stated one way or the other if they are even working on a Community Edition or not, let alone an ETA for it.
  4. Fr0sT.Brutal

    Organizing enums

    Hmm, I think of enums like of an abstraction. I don't care what number has "enumFoo", I often won't notice if it had no number at all. All I want is that "enumFoo" is member of type "TEnumFoo" and (sometimes) that it goes after "enumLaz" and before "enumBar". If I need to let it go beyond my application, I'll use its string name "enumFoo" or special string from "FooNames: array[TEnumFoo] of string". Number values are applied only when I'm sure the definition of enum is consistent (f.ex., between two apps of the same complex).
  5. Not really. People volunteered for it. Some do smaller tasks like testing, but most of the work has been done by the core team. I see it as part of the things MVPs do.
  6. Christoph Schneider

    Firebase

    Do you know the open-source library FB4D for connecting several Firebase services from a Delphi application by using the Firebase Rest API? See more here: https://getitnow.embarcadero.com/FB4D-1.1/ Maybe you don't have to write the connection yourself. There is also a documentation available: https://github.com/SchneiderInfosystems/FB4D/wiki
  7. OverbyteIcsWSocket: ~25500 lines 😄 😞 OverbyteIcsWSocket is not a main unit. And it includes 18 other units (not counting the standard Delphi units). The first code line is line 4800. There are THOUSANDS of comment lines. The rest is what is really necessary to have a significant socket class which serves as the base for higher protocols. The first version of OverbyteIcsWSocket is dated April 1996. Probably today, 24 years later, I would not write it the same way. I gained some experience during all those years after all.
  8. Fr0sT.Brutal

    Listview control with filtering like File Explorer

    Nothing prevents from inheriting from Richedit and extending its features. If that wasn't done already then seems no one needs it
  9. Fr0sT.Brutal

    Organizing enums

    +1. The most useful and powerful Delphi feature which I miss in other languages. These bunches of constants are just ugly and - what's more important - they do not allow type checking.
  10. dummzeuch

    Does Filter Exceptions make Delphi to steal focus

    Yes, it is the culprit. And unfortunately I see no way to solve this.
  11. I had to disable one of the modules in IDE Fix Pack. In system-wide environment variables, I have created new entry named IDEFixPack.DisabledPatches. Value is: Compiler.KibitzIgnoreErrors After IDE restart, I have not seen this problem anymore.
  12. pyscripter

    Subforum for Python4Delphi

    I would like to use the Delphi-Praxis Third-Party section as a support forum for Python4Delphi. Any idea how a subforum for Python4Delphi can be created?
  13. Anders Melander

    "Debug process not initialized."

    Did you work in IT support before you became a developer? Every time I contact our IT department because there's something wrong with one of the servers, the first thing they ask me is to "restart windows". I've given up on educating them so now I just pretend. My current uptime is 118 days. Try disabling the MadExcept "IDE exception catching". Just to eliminate MadExcept as the cause.
  14. Kryvich

    Organizing enums

    Members of an enum are not objects. For ex. I have IDs of syntax relations of words in a natural language (about 200 IDs). The numerical values of the enumeration members are not important to us, only their names matter. Therefore, there is no need to specify integer values for each member of an enum in your program. 1., 2., 3., 4. - it was the answer to the words of Wirth, which you quoted earlier. Enumerations were invented in order not to use ordinalities of its members directly. And so as not to (accidentally) add, subtract and divide them like numbers. This is Pascal where type safety matters. Headers can use enums as well. It depends on how the С-language headers are translated into Pascal code. With enumerations, you can reorder old values as you want. And nothing will break if the ordinalities are not directly used anywhere. Overcomplication, misuse of software entities.
  15. How to check the zero-based index. How many comparison operations it takes to check the occurrence of a value from 0 .. Count - 1. index, fCount: Integer It would seem that it could be easier and here we write the code: Assert((index >= 0) and (index < fCount), 'Array bounds error') This is exactly the message I saw when rangecheck was on. on my very first and favorite compiler for Pascal - 1 for PDP-11. First love does not rust. This is equivalent to two checks and if you open the CPU window we can see that this is indeed the case. We use commands that take into account the upper sign bit. Oz.SGL.Test.pas.459: fCount := 5; 0066E55D C745F405000000 mov [ebp-$0c],$00000005 Oz.SGL.Test.pas.460: index := -2; 0066E564 C745F8FEFFFFFFF mov [ebp-$08],$fffffffe Oz.SGL.Test.pas.461: Assert((index >= 0) and (index < fCount), 'Array bounds error'); 0066E56B 837DF800 cmp dword ptr [ebp-$08],$00 0066E56F 7C08 jl $0066e579 0066E571 8B45F8 mov eax,[ebp-$08] 0066E574 3B45F4 cmp eax,[ebp-$0c] 0066E577 7C14 jl $0066e58d 0066E579 B9CD010000 mov ecx,$000001cd 0066E57E BABCE56600 mov edx,$0066e5bc 0066E583 B818E66600 mov eax,$0066e618 0066E588 E853C8D9FF call @Assert Some microprocessors have special commands to check the entry of the index, who can perform this check with a single command. But if you use the command of comparing unsigned numbers we can simplify the expression and write the following code Assert(Cardinal(index) < Cardinal(fCount), 'Array bounds error'); and then we can do the same check using a single comparison. This reduces the price of the check by exactly half. Oz.SGL.Test.pas.462: Assert(Cardinal(index) < Cardinal(fCount), 'Array bounds error'); 0066E58D 8B45F8 mov eax,[ebp-$08]. 0066E590 3B45F4 cmp eax,[ebp-$0c] 0066E593 7214 jb $0066e5a9 0066E595 B9CE010000 mov ecx,$000001ce 0066E59A BABCE56600 mov edx,$0066e5bc 0066E59F B818E66600 mov eax,$0066e618 0066E5A4 E837C8D9FF call @Assert Usually when debugging I try to remember to enable rangecheck. But in the release version all checks are usually turned off. That is, in training flights we fly with a parachute. But in the combat flight (in the release version) we leave this parachute at home. Then hackers use it to crack through our programs. Do not forget to check at least the input buffer of your program.
  16. Kryvich

    Organizing enums

    When I need to add a new member to the enum, I ... just insert the new member into the enum. If I had a set of named constants, I would have to renumber all the constants starting from the insertion position. So what about extensibility?
  17. Disclaimer: This is microbenchmark area! Which is why I wrote "sometimes" - but it might be better to write this: if not precondition then raise_some_error; do_stuff into: if precondition then do Stuff else raise_some_error Of course there are other factors - but if we already talk about writing an index check as one instead of two cmp/jxx instructions we might as well talk about that.
  18. santiago

    Delphi 10.4.1 and the IDE FIx Pack

    I cleaned up one project (40K lines of code, ca. 80 units, depends on 21 projects). I cleared the 'Unit Scope Names' from the Project Options to be empty. I had to fix many compile errors (in 47 units) by using the full scoped name (e.g: System.SysUtils, instead of just SysUtils). Delphi Rio 10.3.3 (WITH IDEFixPack) Before the changes this project compiled in ca. 8 seconds After the changes it improved slightly to: ca. 7.7 seconds Delphi 10.4.1 Before the changes: ca. 11.5 seconds. After the changes: 8.7 seconds. Delphi Rio 10.3.3 (WITHOUT IDEFixPack) Before the changes: 18.1 seconds After the changes: 14.5 seconds Ideally you should always use the fully scoped names. I would have never had thought that this would have such an impact on compile time...
  19. Lars Fosdal

    New funcionality proposal

    All my method arguments start with a - regardless of if they are const, var or out.
  20. David Heffernan

    Organizing enums

    That's XE7. It seems to me to be folly to design your code based on an IDE tooling issue, and especially one which is soon to be resolved. Further, the issue at stake here, as always when coding, is far less about the experience when writing code, as the experience when reading code. It's not worth it to reduce the readability of your code to give a minor easing to your experience when entering the code.
  21. Vincent Parrett

    Organizing enums

    My take is what he really wants in code completion that actually works? It bugs the hell out of me that when I'm typing an assignment statement and the left side is an enum, that code completion offers all sorts of crap that is not relevant. If the type isn't found, tell me that.
  22. jbg

    Delphi 10.4.1 and the IDE FIx Pack

    The UnitFindByAlias name is misleading. It doesn't have anything to do with Unit-Aliases. I took the name from the compiler's jdbg file. A much more describing name would be FindUnitByUnitName, because that is what the function actually does.
  23. Anders Melander

    Large address space awareness. How to test properly?

    As long as it doesn't do "pointer math" on the integer value then there shouldn't be problems casting between integer and pointer.
  24. Andrea Magni

    Setting Up in ISAPI

    Sorry for the late @RussellW, sometimes it is hard for me to reply immediately! Glad you sorted it out! Sincerely, Andrea
×