Entrypoint parameters order and naming

The following question was asked on Telegram:

Before asking that question my entrypoint declaration looked like

@sp.entrypoint
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

@sp.entrypoint
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

@sp.entrypoint
def my_entrypoint(x):
    pass

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

So the following

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

is equivalent to

@sp.entrypoint
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.