On 27/04/2021 10:13 pm, Ryan Joseph via fpc-pascal wrote: > value.SortEntities(function(a, b: TEntity): integer > begin > // do stuff > end > );
It seem the beginning of the thread is missing, but I would like to comment on something here - purely based on the example code given. The SortEntities() is defined with a signature of type TComparator, which in turn is a function that takes 2 arguments of type TEntity and returns a integer. Why must the anonymous function repeat all that information again, as shown in the quoted code above? Can't the compiler figure all that out simply by inference? All the developer should have to do is give the 2 parameters a name, and a function body (block of code). Thus you could end up with something like this: value.SortEntities((a, b) -> begin // do stuff with a and b, then // return some integer. end ); Yes, I stole the "->" symbol from another language simply to separate the parameters from the function body. Replace that with any Pascal-like symbol. Regards, Graeme _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal