diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go index 01279038..52662365 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -134,18 +134,19 @@ var Funcs = []string{ "image_config.initialize!(pixfmt u32, pixsub u32, width u32, height u32, num_loops u32)()", } +// The "T" types here are generic placeholders for every "slice U" type. After +// parsing these SliceFunc strings (e.g. in the lang/check package), replace +// "T" with the "◊" diamond to denote a generic slice method, to avoid +// ambiguity with a user-defined, non-generic "T" type. + const ( - GenericReplaceFrom = t.IDSLICE - GenericReplaceTo = t.IDDiamond + PlaceholderOldName = t.IDCapitalT + PlaceholderNewName = t.IDDiamond ) var SliceFuncs = []string{ - // The "SLICE" types here are generic placeholders for every "slice T" - // type. After parsing these strings (e.g. in the lang/check package), - // replace "SLICE" with the "◊" diamond to denote a generic slice method, - // to avoid ambiguity with a user-defined, non-generic "SLICE" type. - "SLICE.copy_from_slice(s SLICE)(ret u64)", - "SLICE.length()(ret u64)", - "SLICE.prefix(up_to u64)(ret SLICE)", - "SLICE.suffix(up_to u64)(ret SLICE)", + "T.copy_from_slice(s T)(ret u64)", + "T.length()(ret u64)", + "T.prefix(up_to u64)(ret T)", + "T.suffix(up_to u64)(ret T)", } diff --git a/lang/check/resolve.go b/lang/check/resolve.go index 6eea8a07..e4026ead 100644 --- a/lang/check/resolve.go +++ b/lang/check/resolve.go @@ -110,8 +110,8 @@ func parseBuiltInFuncs(tm *t.Map, ss []string, generic bool) (map[t.QQID]*a.Func } if generic { for i := range tokens { - if tokens[i].ID == builtin.GenericReplaceFrom { - tokens[i].ID = builtin.GenericReplaceTo + if tokens[i].ID == builtin.PlaceholderOldName { + tokens[i].ID = builtin.PlaceholderNewName } } } diff --git a/lang/token/list.go b/lang/token/list.go index b0484a6c..b27d5220 100644 --- a/lang/token/list.go +++ b/lang/token/list.go @@ -404,7 +404,7 @@ const ( IDThis = ID(0xAB) IDIn = ID(0xAC) IDOut = ID(0xAD) - IDSLICE = ID(0xAE) + IDCapitalT = ID(0xAE) IDBase = ID(0xAF) IDMark = ID(0xB0) @@ -588,7 +588,7 @@ var builtInsByID = [nBuiltInIDs]string{ IDThis: "this", IDIn: "in", IDOut: "out", - IDSLICE: "SLICE", + IDCapitalT: "T", IDBase: "base", IDMark: "mark",