AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Was kompiliert Delphi 10.3.3 da???

Ein Thema von harfes · begonnen am 24. Nov 2019 · letzter Beitrag vom 27. Nov 2019
Antwort Antwort
Benutzerbild von Harry Stahl
Harry Stahl

Registriert seit: 2. Apr 2004
Ort: Bonn
2.558 Beiträge
 
Delphi 12 Athens
 
#1

AW: Was kompiliert Delphi 10.3.3 da???

  Alt 25. Nov 2019, 19:17
OK, schon passiert...
  Mit Zitat antworten Zitat
Fritzew

Registriert seit: 18. Nov 2015
Ort: Kehl
678 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Was kompiliert Delphi 10.3.3 da???

  Alt 25. Nov 2019, 19:31
Ich arbeite zur Zeit viel mit Remobjects Elements (früher mal Delphi Prism)

Die Erweiterungen die Remobjects da gemacht hat gefällt mir wirklich gut:
aus der Dokumentation: https://docs.elementscompiler.com/Ox...atements/With/
Es lohnt sich mal in die Dokumentation zu schauen .... Remobjects hat meiner Meinung nach die Sprache super aufgewertet....

Zitat:
The with can be used to temporarily introduce new members in the scope. It supports multiple with items seperated by a comma. The main benefit of with over using a regular local var declaration is that with more explicitly limits the scope of the new variables to the statement or block of statements it applies to. The do keyword can be followed by a single statement or a begin/end block grouping multiple statements.

Delphi-Quellcode:
with fb := CalculateFooBar do begin
  writeLn(fb);
end;
// fb is not available here anymore.
Fritz Westermann
  Mit Zitat antworten Zitat
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.629 Beiträge
 
Delphi 12 Athens
 
#3

AW: Was kompiliert Delphi 10.3.3 da???

  Alt 25. Nov 2019, 21:48
Delphi-Quellcode:
with fb := CalculateFooBar do begin
  writeLn(fb);
end;
// fb is not available here anymore.
Wozu dann überhaupt das with , wenn man doch wieder die Variable fb benutzen muss?

In Delphi würde man das in etwa so schreiben:
Delphi-Quellcode:
  begin
    var fb := CalculateFooBar;
    Writeln(fb);
  end;
  // fb is not available here anymore.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
Fritzew

Registriert seit: 18. Nov 2015
Ort: Kehl
678 Beiträge
 
Delphi 11 Alexandria
 
#4

AW: Was kompiliert Delphi 10.3.3 da???

  Alt 26. Nov 2019, 07:27
Wozu dann überhaupt das with , wenn man doch wieder die Variable fb benutzen muss?
Im Prinzip hast Du recht.... Das geht aber noch weiter:

Zitat:
When the expression for the with statement is a Record or other value type, the new variable acts as an alias to toe original record, and any changes done on the identifier will directly affect the original record.

By contrast, assigning the record to a new local var declaration would create a copy opf the record on the stack:

Delphi-Quellcode:
var x: Person;
x.Name := "Peter";

with y := x do
  y.Name := "Paul";
  
// x.Name is now Paul
Compared to:

Delphi-Quellcode:
var y := x;
y.Name := "Paul";

// x.Name is unchanged, as y is a separate copy
Fritz Westermann
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:42 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz