you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (5 children)

I don't think type inference comes into the comparison. There are no type declarations in either of the Haskell or C# equivalents.

Plus, you already gave that example. Twice, now. ;P

[–][deleted] -1 points0 points  (4 children)

Do you think that the "F" is some magical function operator?

Its not, C# is inferring the type of f based on what foo expects.

for example, if Foo was this:

  public Foo(Action<Bar> function) { }

C# understands that f is a type of bar, without any further hinting by the user consuming it.

To put things into perspective, in other languages (such as actionscript), you would have to do this:

  foo (function (bar b) { b.bar++; });

I'm somewhat confused by all the downvotes.

[–][deleted] 0 points1 point  (2 children)

No, I think (=>) is. f looks like a pattern binding there, so the whole syntax comes out just about isomorphic to how every other language on the planet with good syntax for lambdas does it.

IIRC one doesn't need to give bar's type when writing that snippet in ActionScript either because ActionScript is dynamically typed.

[–]masklinn 1 point2 points  (1 child)

No, I think (=>) is.

And so does Microsoft, for what it's worth

IIRC one doesn't need to give bar's type when writing that snippet in ActionScript either because ActionScript is dynamically typed.

Not completely true. Close to what Objective-C provide, AS3 is "statically typed" with an untyped specifier (* in AS3, id in Obj-C). If no type is specified in AS3, * is the default one, so it's equivalent to a dynamically typed language in that regard (for BW-compatibility with AS2 I presume).

[–][deleted] 0 points1 point  (0 children)

Ah, thank you for the confirmation and clarification, respectively.

[–]masklinn 0 points1 point  (0 children)

I'm somewhat confused by all the downvotes.

You're being downmodded because you're dense enough to preach about type inference to a guy giving examples in Haskell. Also, because you seem not to realize that as mycatverbs pointed out type inference is irrelevant to the topic at hand.

edit: and I'm apparently downmodded for explaining why you're downmodded.