Hacker News new | past | comments | ask | show | jobs | submit login

I guess no. In my use case hundreds of keywords are possible and in the ideal scenario `f(a=1, b=2)` and `f(b=2, a=1)` could be distinguished and saved internally in the order they were given.

There are easy ways around this, e.g. just passing something ordered to `f`, but the keyword argument syntax seems the most concise to me.

Or maybe I do not get you approach - in that case, could you give an example?




Even if you figured out a way to do this, it's wrong wrong wrong. Everyone using an API has a natural and correct expectation that keyword arguments will be order-insensitive. Making them order-sensitive is just begging for trouble.


If they are, by default, order-insensitive, then it should pose no problem at all to make them order-sensitive, since you would not know what order they would appear in either way.

Now, if you had said the other way around (ppl expect them to be order-sensitive but they are order-insensitive), that would have made sense...


No. Because normal behaviour is order-insensitive, I expect that f(a=1,b=2) and f(b=2,a=1) should have identical behaviour. If you make the arguments order-sensitive, then they may not. If, for readability reasons, I change the order of the arguments, I will then be surprised when my code stops working.

Conversely, If (because I think it is order-sensitive) I believe that, in order to make the function do what I want, I have to call f(a=1,b=2) and not f(b=2,a=1), then I'm not going to change the order willy-nilly, so I won't be affected by my expectations not matching reality.


How about passing an ordered dict?




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: