Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-06

Defenition of destructor behind property

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Joost van der Sluis

Hi all,

This construct is accepted by the compiler:

  Tdm = class(TDataModule)
    IBConnection1: TIBConnection;
    procedure DataModuleCreate(Sender: TObject);
  private
    function GetOnderdelen: TXMLDocument;
  public
    property Onderdelen: TXMLDocument read GetOnderdelen;
    destructor Destroy; override;
  end;

Note the 'destructor' behind the property definition. Isn't this a bug? (The Lazarus codetools choke on it)

Joost.

Reply by email

Jonas Maebe
to Joost van der Sluis
Joost van der Sluis wrote 12 lines
Tdm = class(TDataModule) IBConnection1: TIBConnection; procedure DataModuleCreate(Sender: TObject); private function GetOnderdelen: TXMLDocument; public property Onderdelen: TXMLDocument read GetOnderdelen; destructor Destroy; override; end; Note the 'destructor' behind the property definition. Isn't this a bug?

No.

Jonas

Reply by email

Mattias Gaertner
to Joost van der Sluis: This construct is accepted by the compiler: Tdm = class(TDataModule) IBConnection1:…

 
 

Joost van der Sluis hat am 9. Juni 2011 um 12:53 geschrieben:

Show quoted text 16 lines
Hi all, This construct is accepted by the compiler:    Tdm = class(TDataModule)      IBConnection1: TIBConnection;      procedure DataModuleCreate(Sender: TObject);    private      function GetOnderdelen: TXMLDocument;    public      property Onderdelen: TXMLDocument read GetOnderdelen;      destructor Destroy; override;    end; Note the 'destructor' behind the property definition. Isn't this a bug? (The Lazarus codetools choke on it) 

It works here. 
 
Mattias

Reply by email

Hans-Peter Diettrich
to Joost van der Sluis: This construct is accepted by the compiler: Tdm = class(TDataModule) IBConnection1:…
Show quoted text 13 lines
This construct is accepted by the compiler: Tdm = class(TDataModule) IBConnection1: TIBConnection; procedure DataModuleCreate(Sender: TObject); private function GetOnderdelen: TXMLDocument; public property Onderdelen: TXMLDocument read GetOnderdelen; destructor Destroy; override; end; Note the 'destructor' behind the property definition. Isn't this a bug?

Not really. The only strong (syntactical) order requirement exists for fields, which can occur only at the begin of a visibility section. All other declarations, of methods, properties etc., can be recognized by their leading keywords, so that they can be mixed freely. What does not mean that they ever *should* be mixed up (semantics)!

(The Lazarus codetools choke on it)

This is what I'd consider a bug, in the codetools.

Above code looks to me as if Onderdelen [Dutch?] had been a field before, and has been turned into a property later. In so far I'd vote for sorting properties after fields, and before methods. Unfortunately the *convention*, inherited from Delphi, is the opposite: properties should come after methods.

The new Delphi syntax added Var, Const and Type sections to the class declarations, so that fields can be recognized better (as Var), but I don't like that bloat and all consequential problems :-(

DoDi

Reply by email

Mattias Gaertner
to Hans-Peter Diettrich
Show quoted text 19 lines
Joost van der Sluis schrieb: > This construct is accepted by the compiler: > > Tdm = class(TDataModule) > IBConnection1: TIBConnection; > procedure DataModuleCreate(Sender: TObject); > private > function GetOnderdelen: TXMLDocument; > public > property Onderdelen: TXMLDocument read GetOnderdelen; > destructor Destroy; override; > end; > > Note the 'destructor' behind the property definition. Isn't this a bug? [...] > (The Lazarus codetools choke on it) This is what I'd consider a bug, in the codetools.

Again: It works here.

Mattias

Reply by email

Michel Catudal
to Mattias Gaertner
Mattias Gaertner wrote 28 lines
On Fri, 10 Jun 2011 02:45:47 +0200 Hans-Peter Diettrich wrote: > Joost van der Sluis schrieb: > >> This construct is accepted by the compiler: >> >> Tdm = class(TDataModule) >> IBConnection1: TIBConnection; >> procedure DataModuleCreate(Sender: TObject); >> private >> function GetOnderdelen: TXMLDocument; >> public >> property Onderdelen: TXMLDocument read GetOnderdelen; >> destructor Destroy; override; >> end; >> >> Note the 'destructor' behind the property definition. Isn't this a bug? > [...] >> (The Lazarus codetools choke on it) > This is what I'd consider a bug, in the codetools. Again: It works here. Mattias _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel
Tired of Microsoft's rebootive multitasking? then it's time to upgrade to Linux. http://home.comcast.net/~mcatudal

Reply by email

Marco van de Voort
to Hans-Peter Diettrich: Not really. The only strong (syntactical) order requirement exists for fields, which can…

In our previous episode, Hans-Peter Diettrich said:

Show quoted text 8 lines
> property Onderdelen: TXMLDocument read GetOnderdelen; > destructor Destroy; override; > end; > > Note the 'destructor' behind the property definition. Isn't this a bug? Not really. The only strong (syntactical) order requirement exists for fields, which can occur only at the begin of a visibility section.

For ordinary fields maybe. Union (case... of) fields must be at the end.

IIRC this is currently broken in FPC.

Reply by email

Hans-Peter Diettrich
to Marco van de Voort
Show quoted text 10 lines
In our previous episode, Hans-Peter Diettrich said: >> property Onderdelen: TXMLDocument read GetOnderdelen; >> destructor Destroy; override; >> end; >> >> Note the 'destructor' behind the property definition. Isn't this a bug? > Not really. The only strong (syntactical) order requirement exists for > fields, which can occur only at the begin of a visibility section. For ordinary fields maybe. Union (case... of) fields must be at the end.

This is not a strong requirement, because "case" is the keyword for such sections.

DoDi

Reply by email