> -----Original Message----- > From: Christian [mailto:christians / syd.microforte.com.au] .. > Oh yes. I was amazed at how much ML looked like what I developed as a style > for C++. Partial specialisation is just like ML's ability for a function to > be different things according to the arguments. You can take my comment about FP literal - the syntax sucks but the principle is the same. // compile as g++ -template-depth-1000000 -o ack ack.cpp #include <iostream> template <int l, int r> struct ack { static const int res = ack<l-1,ack<l,r-1>::res>::res; }; template <int l> struct ack<l,0> { static const int res = ack<l-1,1>::res; }; template <int r> struct ack<0,r> { static const int res = r+1; }; main () { cout << ack<3,9>::res; }; Ruby IMO actually lacks good support for generic programming and is IMO not particularly suitable for symbolic computations (that might include parsers etc. and I am not talking about speed) - witness the implementation of ``polynomial.rb'' or try to decipher the machine translation of the relevant discussion on the japanese math-ruby ml - the lag of generics is almost staring at you. In C++ you would implement something simple like ZZ/(n) (sorry for the math lingo) class ComRing { // maybe create a top abstract class }; template <unsigned int n> class ZZ_mod : public virtual ComRing { static const unsigned int N = n; // implement constructors and arithmetic operations // which depend on the class constant N. }; try to express this in Ruby - it is going to be a nightmare. There are a lot of competent people who consider a lack of support for generics as a language deficiency - for example support for generics in java http://java.sun.com/aboutJava/communityprocess/jsr/jsr_014_gener.html is probably only a matter of time now and adding generics to FP languages seems to be an active research area. It is true that by virtue of having untyped functions there isn't a crying need for some of the templated functions but adding type (Class) constructing generics (possibly with partial instantiation) is something which IMO could benefit ruby. Enough of this rant - it won't happen anyway and ruby is quite convenient for a lot of things and is rather pretty and consistent as well. I also got the distinct impression that at lot of people are attracted to it because of the relative ease to write C/ C++ extension for it (I did not try the ladder one yet) - IMO as usual. > Except, the expression is far cleaner in ML than in C++. I found myself > writing really cool stuff that can't be used because no-one else understands > it (or it breaks the compiler). But all I was doing (unbeknownst to me at > the time) was trying to do what functional programmers take for granted: > strong static typing with the ability to construct type systems and program > flow at compile time. In both approaches, the effort is in getting a clean > compile -- the rest is academic. > > I became frustrated at how tantalisingly close partial specialisation was to > what I wanted to say. > > Sadly, I am not very familiar with the mathematics behind FP, and this is > the wrong forum to ask about it anyway. I should have payed more attention > to discrete math at University. Off to the bookshop with you, Christian. Functional programming languages like haskell are very good for writing domain specific languages (I am just babbling here) - since this is what you seem to be doing you might as well join their ML. Christoph ..