From 9b4f50cde9d89e2f4ac86ea9bf2dca10fe179792 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Wed, 22 May 2019 13:59:04 -0400 Subject: [PATCH] lang: Add the NamedArgs interface This lets you specify which args are being used in the general function API, which can make code readability and debugability slightly better. In an ideal world, we wouldn't need this at all, but I can't figure out how to avoid it at the moment, so we'll include it for now, as it's always easy to delete if we find a more elegant solution. --- lang/interfaces/func.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lang/interfaces/func.go b/lang/interfaces/func.go index 2387215c..e18f35cb 100644 --- a/lang/interfaces/func.go +++ b/lang/interfaces/func.go @@ -90,3 +90,14 @@ type PolyFunc interface { // are all that should be needed or used after this point.) Build(*types.Type) error // then, you can get argNames from Info() } + +// NamedArgsFunc is a function that uses non-standard function arg names. If you +// don't implement this, then the argnames (if specified) must correspond to the +// a, b, c...z, aa, ab...az, ba...bz, and so on sequence. +type NamedArgsFunc interface { + Func // implement everything in Func but add the additional requirements + + // ArgGen implements the arg name generator function. By default, we use + // the util.NumToAlpha function when this interface isn't implemented... + ArgGen(int) string +}