6

C++ templates have type variables and can express lambdas, so they must have System F embedded. But is that exactly where they are located in the lambda cube? Can C++ templates produce new types or express dependent types?

(I originally posted this to Stack Overflow, but they referred me over to here.)

Raphael
  • 73,212
  • 30
  • 182
  • 400

1 Answers1

11

But is that exactly where they are located in the lambda cube?

The lambda cube is not a giant spectrum on which all programming languages can be classified. It is precisely eight languages, which combine a lambda calculus (values abstracted over values) with all possible combinations of three features:

  • Values abstracted over types (parametric polymorphism)
  • Types abstracted over types (kinds / type constructors)
  • Types abstracted over values (dependent types)

So, the C++ template language isn't anywhere on the lambda cube, since it isn't any of those 8 languages.

The second thing to keep in mind is that we can't mix up C++ features and C++ template features. Just because C++ has lambdas, this doesn't (necessarily) mean that its template language has them.

It is possible to ask, which of the three lambda-cube features does C++ have? It would seem that it features the full power of the lambda cube, but I'm not enough of a C++ expert to know for sure.

Joey Eremondi
  • 30,277
  • 5
  • 67
  • 122