These are mixfix or multi-part function names. They are most well known from Smalltalk, introduced in Smalltalk-76:
aBoolean ifTrue: [ ... ] ifFalse: [ ... ]
4 between: 3 and: 5
but they can be included in any language, including with your syntax. My PhD work was with a language called Grace that had almost exactly that, in fact. It even used that form to define its control structures: if (condition) then { ... } else { ... }
was a call to a three-part method name if-then-else
. Each part of the name is followed by an argument list (and perhaps a type argument list), and a following identifier is parsed as beginning another part of the name. Your examples would all be valid and working method calls in a version of that language.
As well as Smalltalk and its derivatives, this sort of construction exists in Agda, Objective-C, Enso, Lean, and a number of other languages. Typically, the entire name is used as a method or function selector, including all of the parts in some canonicalised form. Sometimes only the first part is identifying, and the remainder are only used to label parameters. Both approaches are feasible and have representation, either as sugar for a more standard function call (e.g. in Agda, if_then_else_
with three arguments) or specifically supported as multi-part message sends.
There's no reason for IDE autocompletion to be any more trouble than usual. You will be able to have multiple candidate completions for any given prefix, but that situation exists anyway: whenever a function name is partially-typed, or in a language with overloading. That's not a new issue, and is addressed in existing systems.
For the case where arguments can appear literally anywhere in the name, the completion would presumably be the remainder of the name, which may not be where the next argument would naturally be inserted. Adopting a structured multi-part approach like existing languages do is probably a better choice when this sort of tooling is desirable (and perhaps other times, too).
While this isn't an extremely common syntax, it's one that standard grammars are easily capable of expressing. Any tooling will be able to parse this construction, and only the normalisation of the components into a canonical identifier is an additional step to more typical syntax—and name-mangling isn't so rare, anyway.
You can imagine still-more-flexible paths: with multiple parts to the name, it's plausible to allow declaring methods that identify calls by a pattern describing optional or repeated components, which we did in this DLS'15 paper. You could step back even further than that too and allow still-freer identifier grammars. There's no real obstacle to the limited form in the question except user unfamiliarity: all the parsing, compiling, and run-time issues are fairly trivial.
Add(5).to(complexObject)
, and our Java testing library hasassertThat(complexObject).isEqualTo(5);
, which are close emulations of this feature. $\endgroup$[foo convertTo: bar withAccessories: baz]
. This version of the syntax doesn't leave any ambiguity about what is a function call. $\endgroup$