Sign in Join

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

Mailing lists / fpc-pascal / 2011-04

"is" for class references

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Mark Morgan Lloyd

Is there an equivalent to "is" for class references?

type    CNodeContent= class of TNodeContent;
   procedure walkContent(node: CNodeContent);
   begin
     Write(PadRight(OidToStr(node.GetOid), 32));
     if node is TScalar then
       Write('  s');

Compilation fails at that point:

test2.pas(46,13) Error: class type expected, but got "CNodeContent"
test2.pas(46,13) Error: Incompatible type for arg no. 2: Got
"CNodeContent", expected "TObject"
Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Mark Morgan Lloyd
to Marco van de Voort
Marco van de Voort wrote
In our previous episode, Mark Morgan Lloyd said: > Is there an equivalent to "is" for class references? yes. classref.inheritsfrom(TClassType)

Thanks, works like a charm :-)

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]