Skip to main content
15 events
when toggle format what by license comment
Jun 17, 2020 at 9:03 history edited CommunityBot
Commonmark migration
Jan 12, 2017 at 22:32 comment added VisualMelon @milk C# will never assume dynamic unless it's the natural consequence of the type inference, but you can indeed write almost anything in a lambda as long as you assign it to a lambda with the right number of (dynamic) parameters. C# also never guess pointer types (even if it could in theory know it's a pointer, it has no idea what type it points to).
Jan 12, 2017 at 19:58 comment added Nathan Merrill I don't know C# very well, but I imagine that a C# lambda would only compile if it knew the types of the variables or that the variables were declared dynamic. Meaning that you still have the dependency to outside code.
Jan 12, 2017 at 19:01 comment added milk Is there an actual C# example where the type cannot be deduced since you can just use dynamic to cover almost everything? Off the top of my head, only pointer types that specifically use the pointer operators can't be dynamic in which case you can deduce it's a pointer type.
Jan 11, 2017 at 0:23 comment added Nathan Merrill Yes, but the difference is that the lambda depends on those types being declared. It isn't standalone, because it is obtaining functionality based on surrounding code
Jan 11, 2017 at 0:19 comment added xnor Maybe I'm not understanding the situation, but shouldn't I expect the types of the inputs to be declared in whatever hypothetical test framework is being used to test the function?
Jan 10, 2017 at 22:02 comment added Nathan Merrill The type is still required: it's just located wherever you declare the type of the variable being passed in. I'm simply moving that type to the lambda
Jan 10, 2017 at 21:59 comment added Pavel Yeah, but the type doesn't have to be declared. For example, the function castToDouble() take an expression in the form of n->n as a parameter without the need for a type declaration.
Jan 10, 2017 at 21:47 comment added Nathan Merrill The key difference here is that Java is manifestly typed. Python doesn't require that the definition exists (you could simply implement __attr__). However, for a Java program to be compilable, that type must declared somewhere. We are simply requiring that the submission has that type.
Jan 10, 2017 at 21:31 comment added Pavel Other languages have lambda expressions which fail if you provide the wrong types. Why is lamda f: allowed in python but f-> is banned in Java? It's the same thing. If you write lambda f:f.sort() in python, it will fail if you pass it an int. If you write f->java.util.Arrays.sort(f), it will also fail if you pass it an int.
Jan 10, 2017 at 21:31 history edited Nathan Merrill CC BY-SA 3.0
added 209 characters in body
Jan 10, 2017 at 21:15 history edited Nathan Merrill CC BY-SA 3.0
added 194 characters in body
Jan 10, 2017 at 21:09 history edited Nathan Merrill CC BY-SA 3.0
added 194 characters in body
Jan 10, 2017 at 20:13 history edited Nathan Merrill CC BY-SA 3.0
deleted 84 characters in body
Jan 10, 2017 at 20:05 history answered Nathan Merrill CC BY-SA 3.0