Re: Function minimization and random numbers



Jon Harrop <usenet@xxxxxxxxxxxxxx> wrote:
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.

It seems to me like *you're* making the artificial distinction here.
You can build closures in C# just fine according to every definition of
closure I've seen.

That's not to say that you can use every member *as* a closure, but to
me that's not the same thing at all. Claiming that C# lacks closures is
pure FUD in my view.

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".

No, then you could say "C# supports first-class closures in the same
way that F# does". Can you find a generic computer science definition
of closures that C#'s support doesn't fulfil?

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
.



Relevant Pages

  • 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
    ... Jon Skeet wrote: ... In what way does C# lack closures? ... Closures represent all functions but .NET delegates do not because .NET ...
    (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: Benefits of Dynamic Typing
    ... > Jon Harrop wrote: ... The simplest example is the exponential complexity of ML's type inference. ... hand (no native closures) as well as their lifetimes. ...
    (comp.lang.functional)