Indeed, thanks for the sample. With Delphi7 you get same output as the
output for FPC you got. Also at the modified version you suggested you get
the error "Operator not applicable to operand type" (at the "self is TA"
line) at compile time, so it's similar behaviour
I wonder if I mixed it in my mind with Java. Now that I think of it there's
a chance that in Java if it allows you to call a static method upon an
instance of a class, the "this" pointer has a value, but if you call it upon
the class itself the "this" pointer is null. I may be wrong with that too,
will have to try it and see (if that's wrong too I don't remember how the
original wrong info on class method behaviour in Delphi got in my mind - it
keeps no backtracking info unfortunately ;-)
greetings,
George
> This is not true for FPC (test it), and I can't imagine it
> would be true for Delphi. Also see my other mail.
>
> No matter whether you call a class method on a class or on an
> instance, 'self' will always be a class, not an instance!
>
> The following program
>
> {$MODE OBJFPC}
>
> type
> TA = class
> class procedure Fn;
> end;
>
> class procedure TA.Fn;
> begin
> if self=TA then writeln('self=TA');
> end;
>
> var
> A:TA;
>
> begin
>
> TA.Fn;
>
> A:=TA.Create;
> A.Fn;
>
> A.Destroy;
>
> end.
>
> outputs
>
> self=TA
> self=TA
>
> Changing TA.Fn to
>
> class procedure TA.Fn;
> begin
> if self=TA then writeln('self=TA');
> if self is TA then writeln('self is TA');
> end;
>
> gives (correctly!) the compiler message
>
> classmethods.pas(11,13) Error: class type expected, but got
> "Class Of TA"
> classmethods.pas(11,13) Error: Incompatible type for arg
> no. 2: Got "Class Of TA", expected "TObject"
>
> Regards,
>
> Bram
>
> _________________________________________________________________
> To unsubscribe: mail [EMAIL PROTECTED] with
> "unsubscribe" as the Subject
> archives at http://www.lazarus.freepascal.org/mailarchives
>
_____
avast! Antivirus <http://www.avast.com> : Outbound message clean.
Virus Database (VPS): 0625-1, 19/06/2006
Tested on: 19/6/2006 5:57:18 ??
avast! - copyright (c) 1988-2006 ALWIL Software.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives