DEV Community

loading...

Discussion on: Comparing function handles across languages

Collapse
sharpninja profile image
The Sharp Ninja

C# 9 added function pointers: spec.

Also, with C# 9 you can have "loose" functions in your code file that includes your Main method.

using static System.Console;

static void Main(string[] args)
{
    WriteLine($"There are {args.Length} arguments.");
}
Enter fullscreen mode Exit fullscreen mode
Collapse
shalvah profile image
Shalvah Author

Function pointers? Interesting. But why? Seems like it's for some lower-level use cases? I couldn't make much sense of the proposal, and there aren't many other materials out there.

Collapse
sharpninja profile image
The Sharp Ninja

C# as a language has matured to the point where there are really talented devs doing amazing things with it in unmanaged code by minimizing allocations and using high-performance techniques from C/C++ in small snippets of performance critical unsafe code but leaving the vast majority of the code to be managed by the CLR, JIT and GC.