Sven, in the with regards to "of course", I think you have it reversed. Is
and as were being used as a class in my test, not an object.
All examples in {$mode delphi}
if Form1.Components[I] is T then // does not compile in my test
while
if Form1.Components[I].Inheritsfrom(T) // did compile
In essence, I could not use "is" or "as". Here is a test:
function TestIsAs<T>(Item: TObject): T;
begin
if Item is T then
begin
Exit(Item as T);
end;
Result := nil;
end;
Result - Error: Class or interface type expected, but got "T" (on line "if
Item<error here> is T then")
With regards to constraints, I tried them previously, but went back to test
them again realized that with class methods the constraint must be in the
method declaration of the class only.
That is:
type
TConstraintMethodTest = class
public
procedure SomeTest<T: TComponent>(Value: T);
end;
// Below is wrong
procedure TConstraintMethodTest.SomeTest<T: TComponent>(Value: T);
begin
end;
// This works
procedure TConstraintMethodTest.SomeTest<T>(Value: T);
begin
end;
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal