While browsing System.Zip (Delphi XE2) to see how it works, I found this function:
procedure VerifyWrite(Stream: TStream; var Buffer; Count: Integer);
begin
if Stream.Write(Buffer, Count) <> Count then
raise EZipException.CreateRes(@SZipErrorWrite) at ReturnAddress;
end;
It's the at ReturnAddress
part that sort of puzzles me.
I didn't know that at
was a valid keyword (the syntax highlighter doesn't seem to recognise it either).
According to the IDE it's declared as System.ReturnAddress
, but I can only find it declared as a label somewhere in the (asm) code of procedure _HandleAnyException;
. The system unit is full of references to it though.
So what I would like to know is this:
- What is
ReturnAddress
?
- What exactly does
Raise Exception.Create ... at ReturnAddress
do?
Bonuspoints if you can give a real-world example of where this would be a useful construct, or if you can advice against using it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…