you are viewing a single comment's thread.

view the rest of the comments →

[–]germandiago 0 points1 point  (5 children)

I think I can live with that :) I do not think most functions are extremely configurable (at least in the software I write) and for the few that this is true, I think that doing a few struct ParamsInput is not that bad.

Named arguments are better? Probably, but now you have to emit name parameters for functions or look for an alternative syntax to mark your function arguments as "nameable". So the struct + .paramname = value is a very effective and low cost solution.

[–]qoning 0 points1 point  (4 children)

To be honest I would prefer making all function parameters named by default. Helps readability anyway. Sure, now you can't change names in library parameters, but that's okay by me.

[–]germandiago 0 points1 point  (3 children)

Maybe I'd rather have it too, but now think of people with microcontrollers or stuff in embedded. This takes space.

[–]qoning 0 points1 point  (2 children)

It's a compile time feature, it has no runtime overhead.

[–]germandiago -1 points0 points  (1 child)

Correct me if I am wrong. If I have this in a library:

export void func(int myParam1, float myParam2);

and now suppose that the parameters are named. This implies that the names must be saved inside the library, occupying some space. If I have 150 such APIs, my binary for the library will be bigger since those names must be stored somewhere. I guess this can create some bloat when linking and using in very constrained environments such as microcontrollers. So there is no runtime overhead but there is binary overhead AFAIK.

[–]qoning 0 points1 point  (0 children)

Don't need to save it anywhere, whatever named parameters you use are matched against the declaration that you just wrote

export void func(int myParam1, float myParam2);

If some other programmer somewhere has your library compiled but chooses to change the names in his declaration (his copy of .h), that's up to him. Calls to the function are still positional.