Re: Function minimization and random numbers



Jon Skeet [C# MVP] wrote:
Jon Harrop <usenet@xxxxxxxxxxxxxx> wrote:
Marc Gravell wrote:
Cheers for that; of course, it is double edged if "standard" .NET
consumers can't use the F# libs... but there we are ;-p

You can write libraries in F# that other languages can use but, of
course, you must avoid features (e.g. closures) that C# and VB lack.

In what way does C# lack closures? It supports them in the form of
delegates with captured variables etc. It may not be the same form that
F# uses, but that's not the same thing.

Closures represent all functions but .NET delegates do not because .NET
draws an unnecessary distinction between members and delegates, making them
incompatible. C# inherits this but F# goes to great lengths to remove this
artificial distinction.

You could turn everything into a delegate but, of course, this would not be
an alluring interface for C# users.

To provide first-class closures, .NET (or C#) might replace all members with
properties that return delegates. Then you could say "C# supports
first-class closures".

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?u
.



Relevant Pages

  • Re: Function minimization and random numbers
    ... Jon Harrop wrote: ... Closures represent all functions but .NET delegates do not because .NET ... then you could say "C# supports first-class closures in the same ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Function minimization and random numbers
    ... lacks closures. ... anonymous functions to delegates. ... There is no loss of static type safety. ... Are you claiming that the C# support for closures is useless? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Function minimization and random numbers
    ... Well, .NET's type system makes the distinction, allowing conversions ... lacks closures. ... design but it culminated in F# rather than delegates. ... Are you claiming that the C# support for closures is useless? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Function minimization and random numbers
    ... Closures represent all functions but .NET delegates do not because .NET ... remove this artificial distinction. ... language features, that's fine, but if you want the features to be useful ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help understanding delegates?
    ... Was just trying to get a solid definition of what ... The things you've said that confuse me most are: ... That you've used delegates as collections with no trouble ... Jon Skeet - ...
    (microsoft.public.dotnet.languages.csharp)