-
Content Count
3740 -
Joined
-
Last visited
-
Days Won
188
Everything posted by David Heffernan
-
One more memory leak and FastMM4
David Heffernan replied to Alberto Paganini's topic in RTL and Delphi Object Pascal
Cut this code down to the minimum that leaks. Then debug that. -
One more memory leak and FastMM4
David Heffernan replied to Alberto Paganini's topic in RTL and Delphi Object Pascal
Try finslly still wrong. You must acquire the resource immediately before the try Foo := TMyObject.Create; try Foo.Use; finally Foo.Free; end; As you have it, if an exception is raised before the variable is assigned, you'll call Free on an uninitialized variable. -
One more memory leak and FastMM4
David Heffernan replied to Alberto Paganini's topic in RTL and Delphi Object Pascal
Not the cause of the leak, but each of those calls to TSomeObject.Create needs to be protected in a try/finally -
Again with memory leaks and FastMM4
David Heffernan replied to Alberto Paganini's topic in RTL and Delphi Object Pascal
Free is implemented as if Assigned(Foo) then Foo.Destroy; so those if statements in the previous post are pointless. Call Free unconditionally. -
Even harder than porting to delphi.
-
How to get pointer to record at the top of TStack<T>
David Heffernan replied to Dave Novo's topic in RTL and Delphi Object Pascal
No. It's clear. He wants the address of the record stored internally by the class to avoid a copy. -
How to get pointer to record at the top of TStack<T>
David Heffernan replied to Dave Novo's topic in RTL and Delphi Object Pascal
What value of xxx is to be used? -
How to get pointer to record at the top of TStack<T>
David Heffernan replied to Dave Novo's topic in RTL and Delphi Object Pascal
"may" is rather weak. A more detailed clarification may be useful to the asker, to make it clear that the code you offered does not prevent a copy, and in fact just adds obfuscation. However, it's also possible that there is premature optimisation going on here. -
How to get pointer to record at the top of TStack<T>
David Heffernan replied to Dave Novo's topic in RTL and Delphi Object Pascal
Surely that's just going to copy the record to a temp local, and return the address of that temp local. Or am I missing something? -
Disadvantage of using defined type of TArray?
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Then you end up with different names for the same thing. How can that be better? Refactoring tools get these names changed very reliably. I don't understand why people are scared of changing names. If you aren't prepared to change names then your code will be a mess. -
Disadvantage of using defined type of TArray?
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Now you have the type named incorrectly in thousands of places. It should be called TItemExArray. Seems far worse to me. -
Disadvantage of using defined type of TArray?
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
I can't really see any benefit here. I mean you might think that TItemArray is somehow better than TArray<TItem> but they seem pretty interchangeable to me in terms of readability. And the reader has to trust that convention was followed with TItemArray. -
Class Constructor in Delphi 10.4
David Heffernan replied to chkaufmann's topic in RTL and Delphi Object Pascal
No. It is deterministic. -
Disadvantage of using defined type of TArray?
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Those are two completely different things. One is a generic dynamic array type, the other is a generic method. -
Disadvantage of using defined type of TArray?
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
You are just polluting the namespace for no benefit. Use TArray<T>. -
Class Constructor in Delphi 10.4
David Heffernan replied to chkaufmann's topic in RTL and Delphi Object Pascal
D is a truly wonderful language, and Andrei Alexandrescu's book is by some distance the best programming book I have ever read. -
RTTI in dpr / console app dpr
David Heffernan replied to Attila Kovacs's topic in RTL and Delphi Object Pascal
Basically this then? -
RTTI in dpr / console app dpr
David Heffernan replied to Attila Kovacs's topic in RTL and Delphi Object Pascal
So, is it the case that rtti is generated for types declared in the project file, but these rtti types don't have a qualified name? -
RTTI in dpr / console app dpr
David Heffernan replied to Attila Kovacs's topic in RTL and Delphi Object Pascal
I don't think about you at all. I was interested in the question. Try to view comments as impersonal. That's entirely possible. I'm interested in learning. It's possible that my misunderstanding is because of imprecise statements. It's possible I'm slow on the uptake. To be clear, I thought you said that types declared in the project file had no RTTI. I checked that and was able to retrieve RTTI for such types. I simply don't understand the strength of your reaction. -
RTTI in dpr / console app dpr
David Heffernan replied to Attila Kovacs's topic in RTL and Delphi Object Pascal
My post above demonstrates that RTTI does exist. I think that the real issue is that these types don't have qualified names. -
RTTI in dpr / console app dpr
David Heffernan replied to Attila Kovacs's topic in RTL and Delphi Object Pascal
program Project1; {$APPTYPE CONSOLE} uses System.SysUtils, System.Rtti; type TMyClass = class public procedure Foo; end; procedure TMyClass.Foo; begin end; procedure Main; var ctx: TRttiContext; Method: TRttiMethod; begin Method := ctx.GetType(TMyClass).GetMethod('Foo'); Writeln(Method.Name); Writeln(Format('%p', [Method.CodeAddress])); end; begin try Main; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; Readln; end. This demonstrates that what you said is not correct. -
That's what I mean. Obviously if somebody finds a bug, whoever it is, that's good.
-
Beta testing is no substitute for having your own comprehensive set of automated tests. Beta testing is best used to help identify issues with design. It really shouldn't be used to find implementation bugs. I hope that Emba don't do that. When Emba tell us that they are going to focus on quality, it comes with talk of how many QP issues have been resolved. But for me that misses the point. Unless they are also fixing the development process that allows so many bugs, they will remain stuck on the treadmill, running to stay still.
-
RTTI in dpr / console app dpr
David Heffernan replied to Attila Kovacs's topic in RTL and Delphi Object Pascal
RTTI is available for all types, be they public (interface section), or private (implementation section or project file). -
Typed constants in Delphi.
David Heffernan replied to Mahdi Safsafi's topic in RTL and Delphi Object Pascal
It just goes to show how easy it can be to misinterpret what people mean.