Re: Function minimization and random numbers
- From: Jon Harrop <usenet@xxxxxxxxxxxxxx>
- Date: Wed, 06 Feb 2008 22:39:24 +0000
Jon Skeet [C# MVP] wrote:
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.
C#'s type system makes the distinction, not me.
That is why you must convert a member into a delegate manually in C# when,
in fact, they are both just functions. There's a whole MSDN help page
devoted to this no-op.
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.
Then you are retrofitting language features onto Algol with no regard for
what makes them useful. Provided you just want a list of checkboxes of
language features, that's fine, but if you want the features to be useful
then you're going to have to think a lot more about how they interact.
Claiming that C# lacks closures is pure FUD in my view.
Avoid closures if you want to call your F# libraries from C#.
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".
That is not how F# supports closures.
Consider a language that support integers but imposes a compile time
distinction between even and odd integers for no logical reason. If that
was the only language you knew, would you back it to the hilt because,
technically, you can work around the type system to use all integers?
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?u
.
- Follow-Ups:
- Re: Function minimization and random numbers
- From: Jon Skeet [C# MVP]
- Re: Function minimization and random numbers
- From: Marc Gravell
- Re: Function minimization and random numbers
- References:
- Re: Function minimization and random numbers
- From: Jon Harrop
- Re: Function minimization and random numbers
- From: Marc Gravell
- Re: Function minimization and random numbers
- From: Jon Harrop
- Re: Function minimization and random numbers
- From: Marc Gravell
- Re: Function minimization and random numbers
- From: Jon Harrop
- Re: Function minimization and random numbers
- From: Jon Skeet [C# MVP]
- Re: Function minimization and random numbers
- From: Jon Harrop
- Re: Function minimization and random numbers
- From: Jon Skeet [C# MVP]
- Re: Function minimization and random numbers
- Prev by Date: Invisible App Run
- Next by Date: Re: Invisible App Run
- Previous by thread: Re: Function minimization and random numbers
- Next by thread: Re: Function minimization and random numbers
- Index(es):
Relevant Pages
|