On Sat, 28 May 2022, Hairy Pixels via fpc-pascal wrote:
I’ve had some time to play with this now and my first piece of feedback is that
given my experience with other languages, the most common usage of closures is
by passing them as arguments to functions.
Compared to the other languages I’m using now I’d say that we should be
inferring more of the context of the receiving function type and not requiring
the programmer to type out the full function header as in the example below
(especially in the case there are no local variables declared).
Sort(function(left, right: Double): integer
begin
if left < right then
result := -1
else if left > right then
result := 1
else
result := 0;
end);
It’s hard to say what the best policy is for Pascal but some combination of the
function/procedure keyword, parameter type names and return type could be
omitted or shortened in various ways.
Ah...
The desire to make a programming language terse and unreadable as a consequence.
If you want that, use C#, Javascript or one of the ubiquitous languages for
bracket fetishists.
Scala & Rust top the bill in terms of unreadability.
So no, that's a "No pasarán".
Pascal is verbose and explicit, it enhances readability & clarity of code.
Any proposal to undo that, is not acceptable.
If it was not for Delphi compatibility, I would kick out anonymous functions
outright. Local functions can fulfill the need for closures perfectly,
which results in more readable code as far as I am concerned.
Michael.
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal