2 ms·
Of course he does. And yes, this small syntactic difference does have effects in the real world; rename 'func' to 'delegate', and with the addition of a semicol
by barrkel 16y ago
Of course he does. And yes, this small syntactic difference does have effects in the real world; rename 'func' to 'delegate', and with the addition of a semicolon (at the end of the println() call) this is valid C# code today - but almost noone writes their resource protection using this idiom because it's ugly.
- masklinn 16y ago> this is valid C# code today - but almost noone writes their resource protection using this idiom because it's ugly. Incorrect (and you don't need delegate, C# has lambdas now). It's because C# doesn't use that for its stdlib and instead has a (redundant) special form and defined protocols.
- barrkel 16y agoIt is correct to say that replacing the func with delegate and adding the semicolon makes it valid C# syntax. The correctness of that statement is completely independent of C# lambdas, which are neither a complete subset nor a complete superset of C# anonymous delegates. And it is ugly. It's ugly because the argument list visually expands across more than one line, including whole statements. The "redundant" forms of "using" and "lock" are both more limited than the closure-passing approach, but their limitations haven't been pressing enough to overcome much of tthe ugliness of the closure-as-parameter approach for this specific case of passing a statement block.