HiveBrain v1.2.0
Get Started
← Back to all entries
patterncppModerate

Where are C++ templates inside of the lambda cube?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
thearewheretemplatescubelambdainside

Problem

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.)

Solution

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.

Context

StackExchange Computer Science Q#103401, answer score: 11

Revisions (0)

No revisions yet.