On Wed, 2 Feb 2005 03:43:11 +0900, Joe Van Dyk <joevandyk / gmail.com> wrote: > I understand C++ programming concepts (i.e. Classes, generics, etc). pretty well > > However, I always feel a little lost about stuff that you don't do > (easily) in C++, like first class functions, partials, currying, > reflection, etc. > > Can someone recommend some resources for better understanding of these > weird concepts? Simple explanations: Reflection -- The ability to perform introspection on an object instance to determine what methods, fields, and so forth it has at run-time. Java can do this, as can Ruby. This isn't even a strange functional programming property. First class functions -- This is a property of languages in that a function may be used as though it were most other types of values, e.g. you can pass a function as a parameter to another function (higher-order functions or HOF's), store functions inside variables, make functions that return other functions as their return value and so on and so forth. C has first class functions: look at the qsort standard library function. You pass qsort a function used to compare elements in the array you want to sort. I believe the same is also true of C++ by extension. Partial Evaluation/Currying -- Say we had some function f(x, y, z) with three arguments. If we left the arguments x and y fixed to some constant values, say 1 and 2, we could construct another function of one variable g(z) = f(1, 2, z). Currying or partial evaluation is the process of doing this. If you ever took a course in the theory of computation, you'll recognize this as a direct application of S.C. Kleene's S-m-n theorem, so in theory any language that has first class functions can define a currying HOF that takes a function of m+n arguments, constant values for m arguments, and return a function of n arguments that computes the original input function with m variables fixed. Some languages (like Standard ML or OCaml) make this process trivial because it is inherent in their syntax, and some languages with first-class functions make it inordinately difficult to do in its fullest generality because of their syntax (I can't think of how to do it in C, for instance). Ruby falls somewhere in the middle, as the Wiki link Mr. Klemme points out shows.