3 ms·
Actually you could say that functions in C# have been first-class since version 2.0. We of course need to define what first-class is ... if it's the ability to
by bad_user 17y ago
Actually you could say that functions in C# have been first-class since version 2.0.
We of course need to define what first-class is ... if it's the ability to have higher-order functions, than 2.0 fits.
C# 3.0 only adds a light-weight syntax for anonymous delegates plus the really kick-ass ability to get a syntax tree of that method instead of the method's reference (on which Linq is based) ... and I really wish other languages add this capability (it was possible in Ruby 1.8.x, but it's not anymore in Ruby 2.0).
Python kicks ass in regard to first-class functions ... and it leverages that ability with decorators. People using other languages go through great pain to have AOP capabilities (for example), but in Python it only takes like 10 minutes to add a couple of utilities to do whatever you want.
The only frustration I have with it is the lack of multi-line anonymous blocks, but Python is so flexible you can add that using "with" block hacks, like described here ... http://billmill.org/multi_line_lambdas.html http://billmill.org/multi_line_lambdas.html
Also, once you understand dynamic-scoping ... it's really not that big of a deal to deal with the situation described above. It's just different.
I like the lexical-scoping in Perl as it prevents all kinds of errors ... but in Python I have real exception-handling, and a kick-ass debugger console just by adding "import ipdb; ipdb.set_trace()" anywhere I want.