Future: On value-based generic arguments for functions

I think once upon a time we thought it would make parsing and type-checking simpler if we could assume that attaching angle brackets to something always meant it was a type, but I'm not sure that's true any more. (That same line of thought led to [Foo.Bar]() not working for a long time even though Array<Foo.Bar>() was fine.) It's entirely possible that today's compiler could support this pretty easily, but I haven't looked into it recently.

One interesting note is that not having this sometimes makes source-compatible changes easier. For instance, a second generic parameter can be added to a function as long as all existing calls continue to work. Generic parameters in functions can also be reordered freely, which they can't be in classes. (I'm not sure why someone would go out of their way to do this, but maybe a bunch of different functions were added separately and now someone is tidying them up to be consistent.)

@Douglas_Gregor, do you remember any more history here?

7 Likes