A macro should be able to tell if a function was passed in most cases at runtime.
Allen Madsen http://www.allenmadsen.com On Fri, Jan 15, 2021 at 2:26 AM Fernando Tapia Rico <[email protected]> wrote: > One benefit of implementing it with functions is the is_function guards, > which provide a better user experience in case of bad arguments :) > > On Friday, January 15, 2021 at 7:35:58 AM UTC+1 José Valim wrote: > >> Alright, please send a pull request so we can also collect the feedback >> of the rest of the Elixir team. :) >> >> On Fri, Jan 15, 2021 at 00:50 [email protected] <[email protected]> >> wrote: >> >>> Thanks Jose and Christopher for your replies! >>> >>> > I am worried making it a macro will signal to developers they need to >>> worry about these kinds of low-level optimizations, which is not generally >>> true! >>> >>> I agree this is a legitimate concern and I totally understand if you >>> prefer to keep this a function. >>> I'm a bit biased because I spent some time lately on some low-level >>> optimizations, which are indeed not very representative of the typical use >>> cases. >>> >>> I probably wouldn't even have thought about it if these functions >>> weren't part of Kernel, which seems to be made of many macros already >>> (searching for *(macro)* in the Kernel docs yield 58 results!). >>> So it might not be such a strong signal in this particular case? >>> >>> > Devil's advocate, one (of many) reasons why dev's shouldn't need to >>> worry about these kinds of optimizations is because the language is >>> conscientious about doing them for devs! >>> >>> I think this is the main argument: if the idiomatic way is also the most >>> performant possible, you don't even have to think about it and to choose >>> between the two. >>> But this thinking taken to an extreme could lead to much overkill >>> complexity, so the question I suppose is about whether it is relevant or >>> overkill in this particular case? >>> I honestly wouldn't know :) >>> >>> Le vendredi 15 janvier 2021 à 05:21:33 UTC+9, [email protected] a >>> écrit : >>> >>>> > I am worried making it a macro will signal to developers they need to >>>> worry about these kinds of low-level optimizations, which is not generally >>>> true! >>>> >>>> Devil's advocate, one (of many) reasons why dev's shouldn't need to >>>> worry about these kinds of optimizations is because the language is >>>> conscientious about doing them for devs! >>>> >>> -- >>> >> You received this message because you are subscribed to the Google Groups >>> "elixir-lang-core" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> >> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/elixir-lang-core/1581c1d4-6d38-418d-ab3b-78c2fe3ed4a0n%40googlegroups.com >>> <https://groups.google.com/d/msgid/elixir-lang-core/1581c1d4-6d38-418d-ab3b-78c2fe3ed4a0n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/d462bbad-457b-4a6d-9180-03f5feff40b4n%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/d462bbad-457b-4a6d-9180-03f5feff40b4n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK-y3Cv-yb_%2B6o1vy1tEVgppL-G7_WhgVJqU9MBjfk7MWAZm0Q%40mail.gmail.com.
