Autor Beitrag
Allesquarks
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Mi 17.01.07 16:40 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TConstant.setto(arg:TConstant);
var temp:TConstant;
begin
  arg.increfcounter;//unbedingt in dieser Reihenfolge, da bei self.setto(self) sonst schon free aufgerufen wird bevor im zweiten Schritt erhöht werden würde.
  temp:=self;
  self:=arg;//wird nicht übersetzt
  temp.decrefcounter;
  self:=arg;//wird nicht übersetzt
end;


Ich verstehe einfach nicht, warum das nicht mitübersetzt wird. Kann ich self in einer Prozedur nicht zuweisen??
Das temp kann man auch weglassen dachte nur vielleicht könnte ich irgendwoeine compilerregel damit vielleicht umgehen.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 17.01.07 17:39 
Moin!

user profile iconAllesquarks hat folgendes geschrieben:
Kann ich self in einer Prozedur nicht zuweisen??

Du kannst auf Self überhaupt nie schreiben. :mahn: Was soll das auch geben, Self ist ja die Referenz auf die Klasseninstanz, in der du da gerade bist; was sollte denn dann da passieren, du kannst ja schlecht durch die Zuweisung die Instanz im Speicher verschieben... :? :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Allesquarks Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Mi 17.01.07 17:43 
Ich will ja gerade auf die Variable ne neue Instanz setzen
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 17.01.07 17:47 
Moin!

user profile iconAllesquarks hat folgendes geschrieben:
Ich will ja gerade auf die Variable ne neue Instanz setzen

Das ist der Punkt, es ist eben keine Variable, sondern nur eine Referenz. ;)

Abgesehen davon: was du damit bezweckst, macht keinen Sinn. Selbst wenn man auf Self schreiben könnte, was sollte denn dann deiner Meinung nach passieren? :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Allesquarks Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Mi 17.01.07 17:52 
Hast recht self ist ja nicht die Variable sondern der Wert ebendieser. Hm wäre aber sehr praktisch gewesen.