On Wed, 2 Feb 2005, Joe Van Dyk 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?

The first three concepts aren't particularly Ruby-ish, they're more
closely attached to functional-programming languages such as Haskell,
CaML, Lambda, etc. However the central feature of those is called
"closure" and you do them in Ruby using proc{} or lambda{} or other. C++
doesn't support those "nested functions". However I think the STL uses C++
classtemplates to wrap single functions in a way that type-decls of C++
can begin to look like functional-programming (that's de hack!).

The latter, reflection, could be thought of just RTTI boosted to the
"max". Actually it doesn't give you so much more in Ruby because all
methods are silent as to the types of arguments they take and what they
give back. However you can at least query classes and walk through
class-hierarchies using ordinary while-loops and recursion, and get a list
of method-defs for each class. You can also do runtime modifications.

However, Ruby's reflection is missing a few things, that are present in
languages like Tcl/Python (examining lists of local variables) or
Scheme/Lisp/Tcl (accessing source code at runtime, as nested lists; easy
manipulation of source code)

_____________________________________________________________________
Mathieu Bouchard -=- Montr?al QC Canada -=- http://artengine.ca/matju