Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Any Existing Languages Allow Function Arguments In Arbitrary Places In A Function Name?

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.

like image 745
Adam Golding Avatar asked Apr 18 '12 03:04

Adam Golding


People also ask

How do you handle arbitrary arguments in Python?

Python Arbitrary Arguments Sometimes, we do not know in advance the number of arguments that will be passed into a function. Python allows us to handle this kind of situation through function calls with an arbitrary number of arguments. In the function definition, we use an asterisk (*) before the parameter name to denote this kind of argument.

What are the types of function arguments in Python?

Give an example. What are the types of function arguments in Python? Hence, we conclude that Python Function Arguments and its three types of arguments to functions. These are- default, keyword, and arbitrary arguments. Where default arguments help deal with the absence of values, keyword arguments let us use any order.

How to handle the number of arguments passed into a function?

Sometimes, we do not know in advance the number of arguments that will be passed into a function. Python allows us to handle this kind of situation through function calls with an arbitrary number of arguments. In the function definition, we use an asterisk (*) before the parameter name to denote this kind of argument.

What is an argument in a function?

An argument is the value that are sent to the function when it is called. By default, a function must be called with the correct number of arguments. Meaning that if your function expects 2 arguments, you have to call the function with 2 arguments, not more, and not less.


1 Answers

Mixfix is the most general form of what is presented above as a Smalltalk syntax feature via Objective-C. Maude's "bubble" parsing is the most clearly documented implementation of this. More generally, google for "mixfix parsing".

like image 172
Brian T. Rice Avatar answered Oct 29 '22 10:10

Brian T. Rice