When we write (in some language or another):
lengthOf(n)
We think of it as short for an english 'fill in the blanks' construction, like:
length of __
But when we write things like these:
isAnInteger(n)
appendTo(n,m)
We think of sentences like:
__ is an integer
append ___ to ___
So, it would seem more natural to allow function invocation expressions like:
(n)isAnInteger
append(n)to(m)
Where the 'function names' are something like:
_isAnInteger
append_to_
Can anyone name existing programming languages which allow this? I know object-oriented languages let the object be one argument at the front, but I am wondering about more flexible syntaxes.
[anObject performOperation:operation withTask:task andInteger:integer]
, etc. It's not flexible per se, but (IMO) reads more naturally. – Oswinto
so that the caller writesn to m
instead ofto(n, m)
. That's not exactly what you're looking for, but it does share some similarities (especially since you can write bothappend
andto
in order to callappend(n to m)
later). – Lorielorien