Okay - there is a difference in the functionality:

inspect/1 does *not* check if the function exists.

the 

literally/1 function also checks if the function was "exported".

Florian Neumann schrieb am Mittwoch, 21. September 2022 um 18:36:47 UTC+2:

> Good find, yes indeed (at least as far as i can see)! Now i can at least 
> get rid of manually importing the helper everywhere.. :)
>
> [email protected] schrieb am Mittwoch, 21. September 2022 um 18:33:27 
> UTC+2:
>
>> I like this idea. In your implementation, wouldn’t `inspect/1` do the 
>> same as your `literally/1`, more or less?
>>
>> ```elixir
>> iex(3)> inspect(&String.capitalize/1)
>> "&String.capitalize/1"
>> ```
>>
>> -a
>>
>> On Wed, Sep 21, 2022 at 12:21 PM Florian Neumann <[email protected]> 
>> wrote:
>>
>>> The example for ExUnit's "Case.describe/2" 
>>> <https://hexdocs.pm/ex_unit/ExUnit.Case.html#describe/2-examples> uses 
>>> a String to reference to the given Function in test:
>>>
>>> describe "String.capitalize/1" do...
>>>  
>>> Changes to the actual implementation (names, arity) are currently not 
>>> picked up by the compiler or test frameworks.
>>>
>>> To help myself out i wrote a helper function "literally/1" which accepts 
>>> a function as parameter and turns it into a fully qualified function 
>>> capture string:
>>>
>>> describe literally(&String.capitalize/1) do...
>>>
>>> This removes potential code smells when referring to functions.
>>>
>>> Having a dedicated function for this adds a lot of clutter (every 
>>> describe line get's expanded and you have to maintain that helper function 
>>> in each project).
>>>
>>> So if this is something improving the developer experience for anybody 
>>> else i'd like to propose the additional acceptance of function-captures as 
>>> first parameter of describe/2:
>>>
>>> describe &String.capitalize/1 do...
>>>
>>> P.s.: i hope i got the terms function capture for function references 
>>> right.
>>>
>>> -- 
>>> 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/3b47d4bf-4e91-4896-8549-a9ffab5890a0n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/elixir-lang-core/3b47d4bf-4e91-4896-8549-a9ffab5890a0n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> -- 
>> Austin Ziegler • [email protected][email protected]
>> http://www.halostatue.ca/http://twitter.com/halostatue
>>
>

-- 
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/ff006de2-6baf-4c8b-9123-4fb742a2a2fen%40googlegroups.com.

Reply via email to