Sign in Join

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

Mailing lists / fpc-devel / 2013-03

Regarding CheckIn #23944

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

kyan

"Don't allow "static" for class operators or normal methods (except in objects)"

http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=23944

Does this mean that the following code:

{$mode=Delphi}
type
  TRec = record
    ...
    class function Empty: TRec; static;
    class operator Equal(A, B: TRec): Boolean; inline; static;
  end;

will not compile?

Mind you Sven, in Delphi XE the "static" directive is allowed for record "class" operators although I don't know if it actually makes a difference to emitted code -I would suspect not since there is no "class pointer" to pass to the method as a first hidden argument, records do not support inheritance and have no VMT. For the same reason "class" functions of records are *required* to be declared as "static".

I believe that you made this change for the same reason, i.e. you imply that class functions and operators of records are inherently static, but this breaks Delphi compatibility especially for class functions.

Constantine.

Reply by email

Sven Barth
to kyan
kyan wrote 7 lines
"Don't allow "static" for class operators or normal methods (except in objects)" http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=23944 Does this mean that the following code: {$mode=Delphi}

Note: No "=" here.

Show quoted text 9 lines
type TRec = record ... class function Empty: TRec; static; class operator Equal(A, B: TRec): Boolean; inline; static; end; will not compile?

Exactly.

Mind you Sven, in Delphi XE the "static" directive is allowed for record "class" operators

It does not allow it. This is precisely the point why I forbid it as well.

Delphi compiler error for the "Equal" line:

"E1030 Ungültige Compileranweisung: 'static'"

aka

"E1030 Invalid compiler directive: 'static'"

Tested on Delphi 2007 and XE.

Regards,
Sven

Reply by email

kyan
to Sven Barth
Sven Barth wrote
Delphi compiler error for the "Equal" line:

Not if you include an "inline;" directive. Then it compiles. If no inline directive I do get an E1030.

Quirk of the XE (i don't have D2007) compiler I guess. I will check with XE3 later and tell you.

So I will have to delete the "static" directive from class operators declared "inline; static;" OK, no fuss.

Thanks.

Reply by email

Sven Barth
to kyan
"kyan" wrote
On Thu, Mar 28, 2013 at 6:53 PM, Sven Barth
> Delphi compiler error for the "Equal" line: Not if you include an "inline;" directive. Then it compiles. If no inline directive I do get an E1030.

Gaaahhhhhh!!!!

I'll tell you... Somewhen I'll go on a killing spree at Embarcadero!

Quirk of the XE (i don't have D2007) compiler I guess. I will check with XE3 later and tell you.

Even if they shouldn't have fixed this I will continue to consider it as a bug...

Regards,
Sven

Reply by email

Sven Barth
to Sven Barth
Sven Barth wrote 7 lines
> > Quirk of the XE (i don't have D2007) compiler I guess. I will check > with XE3 later and tell you. > Even if they shouldn't have fixed this I will continue to consider it as a bug...

Addition: It also does not compile if you do "static; inline;", so I consider this definitely a bug in the Delphi compiler...

Regards,
Sven

Reply by email