Variadic Generics


#1

I came across @eddyb’s old proposal for variadic generics yesterday and it really hit home :smile_cat:!

I’ve come across a couple use-cases over the past few days where I’ve had to fall back to a not-so-elegant solution using macros. Something along these lines would have been perfect!

The proposal looks like it has received quite positive feedback, however it seems to have been placed to the side for now which has me wondering:

What would be the next step in bringing something like this to Rust? Does it require a new RFC (under the new process)? Or is the main thing holding it back simply lack of time and priority to implement it?


#2

The process would be to create an RFC, but there is only the tiniest chance we would accept this pre-1.0, so you’d be better off waiting for 1.0 before doing so.


#3

Wouldn’t this likely have an impact for e.g. the formulation of the function-call-operator traits that we’ll want to nail done before 1.0?


#4

On a whim I went googling, and found this paper about arity polymorphism:

http://www.ccs.neu.edu/racket/pubs/NU-CCIS-08-03.pdf http://www.ccs.neu.edu/racket/pubs/esop09-sthf.pdf

(These are at least 90% the same paper, and merely judging by the URL I suspect the latter is a more recent version, but I’m linking both, just to be sure.)

This appears to be the only rigorous type-theoretic treatment of variadic functions in existence (formulating it as an extension to System F), so I think it deserves to be studied closely in preparation for adding any similar capabilities to Rust. So far I’ve only skimmed it myself.

(cc: @eddyb @pnkfelix)


#5

The latter paper is indeed a revision of the former, but the technical report version has some additional formal material.

There’s also http://www.ccs.neu.edu/racket/pubs/NU-CCIS-08-01.pdf which does much the same thing in a more Java-like context, and which might also be interesting.

Finally, chapter 9 of my dissertation contains a similar discussion.


#6

Nice! I wonder if there’s an accepted term for the phenomenon where you refer to some work, and the author turns out to be among the audience… :slight_smile:

Have you mentioned this somewhere before, and I just hadn’t seen it? Or if not, how come not? Do you perhaps feel it doesn’t have as much relevance as I suspect it might?


#7

I didn’t know that Rust was thinking about this, and I’m merely a bystander to the Rust community. I did mention this to @nikomatsakis recently since he told me at a JS meeting that Rust was thinking about this.