Back to articles
Parameter Objects in MiniScript

Parameter Objects in MiniScript

via Dev.toJoeStrout

Sometimes a function starts out with a reasonable number of parameters, but as the code grows and more features are added, it ends up with more and more — like PixelDisplay.drawImage in Mini Micro , which has 10 parameters. Arguments in a function call in MiniScript are passed by position, not by name, which means that even if some of those parameters are optional, you have to specify all arguments that come before one you actually care about. And of course you have to remember what order they're in. (So many times I have typed @gfx.saveImage at the Mini Micro prompt just to remind myself of the order of the parameters!) Why not passing parameters by name is a good thing Languages that support passing parameters by name encourage developers to make functions with lots of parameters. And then it will turn out that only certain combinations of those parameters make sense, and the function sprouts pages of parameter-checking logic just to ensure that the user is calling it properly, and m

Continue reading on Dev.to

Opens in a new tab

Read Full Article
5 views

Related Articles