- changed status to resolved
object and "with" construction
program test;
begin
Print(TObject.Create.Classname);//thats works fine
// with TObject.Create do //error “Colon ":" expected” throwed.
// Print(Classname);
end.
Comments (3)
-
repo owner -
reporter with obj := TObject.Create do Print(Classname); //error "Unknown name "Classname""
thats mean no sense to use “with….do” constructions for objects.
Ok, well understood, thank you.
-
reporter @Eric Grange
I make alternative with … do realization for correct completion of construction like
with TFileStream.Create(path,mode) do try tempstr := data + #13#10; Seek(0, soFromEnd); WriteBuffer(tempstr,(Length(data)+2)*2); finally Free; end;
can be switched in compiler options.
Do you interested in?
BTW, Free for Delphi objects doesnt called real object Free or Destroy. Also fixed.
P.S. To expand previous question - i have TOO MUCH changes, fixes, remaking etc in DWS since Feb 2022 (have no possibility to make some commits, internet was limited). Some of them, i think, will be principally not interesting for you (like implementing of specialized integer & floating types in addition to common integer and float, Linux & MacOs implementation, etc etc), but not all.
The great problem is to split this changes to commits, so i dont want to spend a lot of time, if you are not interested in.
- Log in to comment
Legacy anonymous "with" constructs are not allowed, you have to use the named aliasing syntax