Entrypoint parameters order and naming

The following question was asked on Telegram:

Before asking that question my entrypoint declaration looked like

def myfunction(params):
    (x, y) = params

these parameters were unnamed in BCD or TZStats and I was seeking a way to describe them. Then I realised my mistake and refactored the entrypoint to

def myfunction(x, y):

Why some entrypoints’ arguments displayed in BCD in the same order as I specified them in the source file and some are reversed, e.g. “y” comes before “x”?

About parameters naming.

If there is only one parameter, SmartPy isn’t naming it.

For example, the following entrypoint would have an unnamed parameter

def my_entrypoint(x):

If there are multiple parameters, SmartPy treat them as a record parameter with field names being the name of the parameters.

So the following

def my_entrypoint(x, y):
    sp.cast(x, sp.int)
    sp.cast(y, sp.int)

is equivalent to

def my_entrypoint(param):
    sp.cast(param, sp.record(x=sp.int, y=sp.int))

In explorers the names are the names of the record fields.

The order or the fields is alphabetical so my_entrypoint(x, y) is the same as my_entrypoint(y, x) as it provides some optimization in Tezos.