How can I create a method with 3 non-keyword parameters?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
nagylzs
Posts: 39
Joined: Sat Jan 19, 2019 8:01 pm

How can I create a method with 3 non-keyword parameters?

Post by nagylzs » Mon Dec 23, 2019 12:10 pm

We have these:

Code: Select all

MP_DEFINE_CONST_FUN_OBJ_1
MP_DEFINE_CONST_FUN_OBJ_2
MP_DEFINE_CONST_FUN_OBJ_3
But there is no

Code: Select all

MP_DEFINE_CONST_FUN_OBJ_4
. Is it intentional? Should I always use mp_arg_parse_all instead for methods with more than 3 parameters (including self)?

stijn
Posts: 409
Joined: Thu Apr 24, 2014 9:13 am

Re: How can I create a method with 3 non-keyword parameters?

Post by stijn » Mon Dec 23, 2019 12:22 pm

It's intentional for the sake of optimization.

See obj.h: more than 3 requires using MP_OBJ_FUN_MAKE_SIG with arguments and the shortcut for that is MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(objName, 4, 4).

nagylzs
Posts: 39
Joined: Sat Jan 19, 2019 8:01 pm

Re: How can I create a method with 3 non-keyword parameters?

Post by nagylzs » Mon Dec 23, 2019 6:09 pm

Thank you!

Post Reply