-
Content Count
3710 -
Joined
-
Last visited
-
Days Won
185
Everything posted by David Heffernan
-
More efficient string handling
David Heffernan replied to parallax's topic in Algorithms, Data Structures and Class Design
vtune with map2pdb is excellent. It will take time to set it up, but it will save you time in the long run. And you'll have a better end result. -
More efficient string handling
David Heffernan replied to parallax's topic in Algorithms, Data Structures and Class Design
Yes. Use a buffered line reader. But more importantly measure where your code spends its time. Don't guess. -
Showing a warning form to some users
David Heffernan replied to Henry Olive's topic in RTL and Delphi Object Pascal
Sounds like you need to build some messaging infrastructure in to your program. -
More efficient string handling
David Heffernan replied to parallax's topic in Algorithms, Data Structures and Class Design
Regarding the code in the previous post, every call to Delete performs both a copy and a heap allocation. You should be able to do this with one heap allocation and one copy. -
Using translations in unit Consts with Delphi 10.4 VCL
David Heffernan replied to Dirk Janssens's topic in VCL
Why isn't the function call mapping to the native TaskDialog and so letting the OS provide the captions? -
TThread instances to run on separate CPU cores.
David Heffernan replied to DavidJr.'s topic in RTL and Delphi Object Pascal
No. There is no problem. If there are multiple threads then the OS will schedule them into different logic processor cores. Always has. You misdiagnosed your problem before. -
TThread instances to run on separate CPU cores.
David Heffernan replied to DavidJr.'s topic in RTL and Delphi Object Pascal
The entire point of a threads are to allow code to execute in parallel in the same process. -
Make a minimal example that we can run. Or just debug your code.
-
'Floating point division by zero' when running script
David Heffernan replied to a topic in Python4Delphi
Yes, through context switches the OS preserves the CPU and FPU state which is part of the thread context -
'Floating point division by zero' when running script
David Heffernan replied to a topic in Python4Delphi
I set the floating point control state to the Windows default (which masks exceptions) before calling any external library, and then restore it when those calls return. In order for this to work reliably in a multi-threaded environment you need to do some serious RTL patching to fix the thread safety issues. No, it is possible to fix the RTL so that you don't require such an invasive solution as you imagine. My numerical software does this. Many years ago I submitted a QC report with the attached document which explains how to fix it. Embarcadero have done nothing yet, although deleting QC meant that my report disappeared from public view! Rethinking Delphi Floating Point Control Register Management.pdf -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
Sure. But there are plenty of methods where you can make changes. Just because something doesn't solve all problems, doesn't mean that solving some problems isn't possible or useful. But for sure in an ideal world we would have in, out and in/out parameters implemented with the same functionality as C#. I'd be very happy to have a breaking change to the compiler and migrate my code to such a language. -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
Indeed. And it is simply the fact that var serves as both in/out and out that explains why there is no such warning for var parameters. Since we have out then a very simple thing for the designers to do would be to enable this very warning for var parameters too. If you encountered it on a var that was masquerading as a pure out parameter, you could simply change the parameter definition to be out. -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
Without the compiler enforcing it, it's next to pointless -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
The thing is, for value types, there is actually no practical difference between var and out in Delphi which is the problem. In practice out and var behave identically. So what's the point of out? I appreciate that legacy makes it hard to change. It was just a screw up by the designers that leads to oddities like the absent warning in this question. -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
A variable has to be initialized before being passed to a ref param -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
Because it has been designed correctly with ref, out and by value arguments handling the three different parameter semantics. C# is an example of how delphi should be, and the entire issue with this missing warning is because delphi is so badly designed in this area. -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
I understand all of that, hence my first post. I explained why Delphi behaves the way it does, because var is both in/out and out. -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
In C# you can't pass an uninitialized variable to a ref param, but you can to an out param. -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
I think this is because Delphi doesn't really distinguish between in/out and out semantics. Since it doesn't know whether var implies in/out or out, it can't warn, because the var parameter may be an out parameter. And yes I know that the out keyword exists but certainly for value types it is purely cosmetic. Contrast this with the clarity of C#. -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
Completely wrong. And rather unhelpfully so. -
Using uninitialized object works on Win32, throws AV on Win64
David Heffernan replied to aehimself's topic in General Help
You weren't lucky. You were unlucky. Lucky would have been if the error had shown itself immediately. No point analysing luck. Fix your code and move on. -
Is Graphics32 ready for Delphi 11 yet?
David Heffernan replied to RCrandall's topic in Delphi Third-Party
@Borut please don't spam the same post. Especially not by adding to the end of another old post. -
sList[1] is likely the issue because sList contains 1 or fewer items. Use the debugger to confirm. Those calls to ProcessMessages look likely to cause you problems. If.not now, some time in the future.
-
There are likely to be other errors in such a migration. It pays to understand.
-
Presednce of operations...
David Heffernan replied to Mark-'s topic in Algorithms, Data Structures and Class Design
If FPC had given 9 that wouldn't have changed the conclusion