Unfortunately it cannot do this in all cases: fun = &IO.inspect/1
foo |> tap(fun) |> blah `tap` as a macro has no ability to know whether `fun` is a function at compile time. On Friday, January 15, 2021 at 1:54:58 PM UTC-5 Allen Madsen wrote: > I meant compile time. > > Allen Madsen > http://www.allenmadsen.com > > > On Fri, Jan 15, 2021 at 1:53 PM Allen Madsen <allen.c...@gmail.com> wrote: > >> 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 <fert...@gmail.com> >> 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 sabi...@gmail.com <sabi...@gmail.com> >>>> 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, christ...@gmail.com 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 elixir-lang-co...@googlegroups.com. >>>>> >>>> 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 elixir-lang-co...@googlegroups.com. >>> 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 elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/df13638a-741c-4fc9-b66b-9f5b7b945bdan%40googlegroups.com.