To answer your question, it's totally a matter of preference, but some devs like the most inner arg - typically data x - to be the first thing they see. So instead of f(g(h(i(x))), if you have (x ->> i h g f), you know right off the bat x is the thing we're working with and it's to go through a series of transformations in the order i, h, g, and f. The benefit of a threading macro becomes more obvious if you have really really nasty nesting going on.
Thanks for the explanation. I can see why it could be easier to know the argument first when tracing through a complex sequence of calls.
Now that I think about it, even in natural language, you can have an instruction like "uppercase the first letter of each word" which makes grammatical sense in english, but then once the instructions become more complex like "uppercase the first letter of every other word whose length > 3", it's easier for me to translate the logic in reverse the same way the thread-macro is written so the the argument in question (each word) comes first.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello! Thanks for visiting.
To answer your question, it's totally a matter of preference, but some devs like the most inner arg - typically data x - to be the first thing they see. So instead of f(g(h(i(x))), if you have (x ->> i h g f), you know right off the bat x is the thing we're working with and it's to go through a series of transformations in the order i, h, g, and f. The benefit of a threading macro becomes more obvious if you have really really nasty nesting going on.
Happy coding!
Thanks for the explanation. I can see why it could be easier to know the argument first when tracing through a complex sequence of calls.
Now that I think about it, even in natural language, you can have an instruction like "uppercase the first letter of each word" which makes grammatical sense in english, but then once the instructions become more complex like "uppercase the first letter of every other word whose length > 3", it's easier for me to translate the logic in reverse the same way the thread-macro is written so the the argument in question (each word) comes first.