Hi, good explanation, that can apply to this the same?
with TStringList.Create do
begin
Free;
end;
Is the same as:
So: Yes.
Of course without "with", that temp var can only be used for one further statement.
It's in the node tree. Looking at the fpc source:
There is a fundamental difference between. "With creates the temp variable" and "The compilers implementation for with has code that creates a temp variable."
I am sure that, if you go through the code of the compiler you can find a lot of things that are done within code for something else.
In that case, "with" is one of many ways to
operate on the result of a function call. So (a copy of) code that is needed for that is included in the implementation of "with".
Reminder, your statement was 2. With doesn't create a temporary object
Provably wrong with the fpc code creating a tempnode
You did not say "the fpc compiler implements a copy of the code for
operate on the result in the code handling with".
You said, that it was the "with" itself that creates the temp variable.
I will give you that, using "with" probably always constituted
operating on the result. Therefore using "with" will always include all the effects that
operating on the result has. But afaik, it is
operating on the result that creates the temp var.
If I said "rounding a floating number creates a new stackframe" most people would (rightly) say that I am wrong.
Of course
calls a function, and calling a function creates a stackframe. But that doesn't mean that the statement above is suddenly correct.
The statement tells a partial true, in such a way that the reader will be led to wrong conclusions. That makes it a false statement.
==> Just to say, if round ends up an intrinsic => chose any other function that actually gets called.