3 ms·
Thanks for these suggestions! Shouldn't there be a way for the compiler to know enough to convert the map to positional arguments, so long as the map params co
by JimmyRuska 6y ago
Thanks for these suggestions!
Shouldn't there be a way for the compiler to know enough to convert the map to positional arguments, so long as the map params could be put into a spec? Something like that would be super nice, because I think tail calls in Erlang cost nothing so long as you keep the same arg positions. Having a map is always a convenient way of starting a function and evolving it, but having it with a few more constraints and with equal performance would be better. If I'm not mistaken I remember dart made a similar optimization.
- toast0 6y agoIf the functions are exported, the compiler wouldn't be able to optimize calls. Dynamic modules and hotloading means there's no expectation that what you had when compiling is what you're running against in production. If they're in the same compilation unit, the newer SSA based optimizer might do some cool stuff for you; it's always interesting to look at the optimized code that comes out of compiling/loading. In general though, I would tend not to worry about efficiency of passing a map instead of traditional arguments. Most likely there's other, bigger, things to worry about; usually finding the right communications patterns and algorithms makes a bigger difference.