Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 06/07/20 in all areas

  1. santiago

    Ctrl Tab Ide Plugin

    The way the Ctrl+Tab shortcut works in the Delphi IDE was always very inconvenient for me. Actually the Delphi IDE is the only program I can think of that does not navigate open documents based on the order in which they were last activated but instead on the order in which the tabs are arranged in the editor. So if you are were working in DocumentPrevious and switch to DocumentNext, I am used to going back to DocumentPrevious by hitting Ctrl+Tab. But in the Delphi you will navigate to whatever document is on the right side of DocumentNext. This has always been very annoying for me. Anyhow I made plugin that makes Ctrl+Tab behave to what I am used to from other programs, like Visual Studio for example. Might be of use for some. https://github.com/santiagoIT/DelphiCtrlTab Precompiled binaries are available for Delphi Seattle, Rio and Sydney.
  2. Vandrovnik

    Strange behavior for literals

    Delphi's "Shifting a 1 63 places to the left in a 32-bit variable" is the same as "Shifting a 1 31 places to the left in a 32-bit variable", so you will get $80000000. In the example above, shifting is done in 64bit variable and the result $8000000000000000 is assigned to 32bit typed constant - lower 32bits are used (0) and a warning is generated.
  3. Hello, I found a very strange behavior about how Delphi handle literals. Here is a quick example (Delphi 10.3) showing what I found : // For each error, read the comment ... comment the line and next. const F1 = 0.2; F2 = Single(0.2); // this is not a single type ... see below ! I1: Integer = F1; // E2010 Incompatible types: Integer and Comp. => F1 = Comp ! I2: Integer = F2; // E2010 Incompatible types: Integer and Extended => F2 = Extended even when specifying it as Single ! ConstInt1 = 1; // primary expression ConstInt2 = +1; // unary expression SizeOfConstInt1 = sizeof(ConstInt1); // size = 1 ! SizeOfConstInt2 = sizeof(ConstInt2); // size = 4 ! FArray = [1, 2, 3] + [4, 5, 6]; // untyped array. function GetFArrayPointerUsingAsm(): Pointer; asm lea eax, FArray[0] // return invalid pointer ! end; procedure ProcessFArray(const X); begin // compiler pushed unkown STACK reference ! end; var len: Integer; size: Integer; P: PInteger; value: Integer = 3; begin len := length([1, 2, 3] + [4, 5, 6]); // len = 6 len := length(FArray); // Error E2008 Incompatible type ! size := sizeof([1, 2, 3] + [4, 5, 6]); // error does not compile. size := sizeof(FArray); // wrong size = 1 ! size := sizeof([1, 2, 3]); // wrong size = 1 ! P := @FArray[0]; // Error E2016 Array type required. P := GetFArrayPointerUsingAsm(); // function returns invalid pointer ! ProcessFArray(FArray); // compiler passed unkown/invalid stack reference ! if (value in FArray) then // Ok. begin Writeln('FArray contains value'); // passed. end; Readln; end. I'm not even going to mention typed constants or constants that may change ! I just believe that it's really the time to consider checking the compiler's const type system.
  4. Mahdi Safsafi

    Strange behavior for literals

    Yes you're right ! Compiler and CPU love UInt32 type ... its the CPU native word ! Even for x64 machine, CPU always prefer UInt32 type over UInt64. And gives much performance against any other type (UInt8, UInt16, UInt64, ...). For performance reason, you should always use UInt32/Int32 type even if your data is less than U/Int32. Final things: M is a UInt64 global variable stored in memory. Meaning you can view/access it as array! When comparing it against UIn32, UInt16, UInt8, the compiler can just compare its elements. However in your example, the compiler generated a non optimized code ! # In fact Its much better to do : cmp (dword|word|byte) [@M + offset], constant # rather than: mov rax, constant cmp qword [@M], rax
  5. santiago

    Ctrl Tab Ide Plugin

    @Kas Ob. Am happy it was useful for you and that you got it to work with D2010. 🙂 No idea about the crash when rebuilding the plugin. The oldest Delphi Version I have tested it with is Seattle and that problem does not occur there. I have never used D2010, that was before I got started with Delphi. If possible you could submit a pull request, might be useful for others as well.
  6. Daniel

    Strange behavior for literals

    @Mahdi Safsafi there is no need to convince someone here. Sometimes we just have different views on an item. This is not wrong by itself. if you think that you have found an error in Delphi, please create a bug-report at quality.embarcadero.com
  7. David Heffernan

    Strange behavior for literals

    I don't think the issue is that I don't see the full picture and have a lack of clarity.
  8. David Heffernan

    Strange behavior for literals

    The inability to control the type of a floating point literal is the only real issue here. Everything else mentioned above can be readily worked around. But the fact that you can't control the type of a floating point literal presents problems that have no workaround. I want to write const s = 0.1s; d = 0.1d; And have two literals with different values.
  9. Mahdi Safsafi

    Strange behavior for literals

    @David Heffernan I believe that you are not seeing the full picture here : The real issue is the dissociative type between literal and expression (not like what you understand "the ability to control FP constants") . BTW you don't work around an issue ... you need to fix it (fixing the type system will let you control FP type) !! This is a critical issue ! For now it just looks less critical but just think if at some time Delphi introduces type inquiring feature ! what will happen ? I was working on a Pascal-like compiler and I used a weak-typed literal system for constants, meaning the const was stored using the longest available type and casted on demand. I got a very surprising result when inquiring types/expressions/variables. This was my motivation to inspect Delphi constants. So I'm very sure that this aspect is wrong and will at some point produce unpredictable behaviors. I hope -by now- that you are seeing the full picture and everything is clear for you.
×