Is there a difference between TParallel.&For and TParallel.For?
Asked Answered
S

1

9

Is there a difference between TParallel.&For and TParallel.For ?

Both can be compiled in Delphi 10 Seattle. so which one should I stick to?

Shayne answered 8/10, 2015 at 11:40 Comment(1)
There is no difference.Holily
W
15

The method definition for TParallel.&For requires the ampersand to escape a reserved word (for). You don't need to use it when calling the method except in cases where there would be ambiguity.

For example :

 with TParallel do begin
    &For(...)  // etc 
 end;

I can't imagine why you would ever want to do that, however.

If it were in one of your own classes, mind you, any internal calls to an escaped method would require either the ampersand or an explicit class or instance (self) identifier.

TParallel is a sealed class, so the point is moot in this case. You will never be working within it or within a descendent class.

Weidar answered 8/10, 2015 at 12:13 Comment(2)
Presumably it's only needed in the declaration of the type and not the implementation?Zebedee
@DavidHeffernan It's also necessary in the implementation. You would think the scope could be resolved at that point, but omitting it in the implementation produces a compiler error (Expected IN but received FOR).Weidar

© 2022 - 2024 — McMap. All rights reserved.