Function type naming conventions (original) (raw)

Dan Smith daniel.smith at oracle.com
Thu Jan 24 10:52:51 PST 2013


On Jan 23, 2013, at 2:20 PM, Brian Goetz <brian.goetz at oracle.com> wrote:

Will do the first part tomorrow unless someone strongly objects.

Open issues: - Where multiple rules apply, do we prefer XY or XToY?

I think it depends on the base type.

ToIntSupplier sounds silly. It's a Supplier, so of course the "Int" qualifier means the thing being returned. (In fact, my inclination is to read this as a "supplier of ToInts", where a "ToInt" is a "ToIntFunction" -- i.e., "ToIntSupplier" = "() -> T -> int".

IntToDoubleFunction, on the other hand, sounds right. An IntDoubleFunction sounds more like a BiFunction<Integer,Double,T>.

Let me propose a slightly different convention: if the base type is parameterized in both its parameters and return, then the "To" prefix is mandatory. If not, "To" is not used.

—Dan



More information about the lambda-libs-spec-observers mailing list