No, they have to "use something". Being unable to have a magic command that
modifies all modules globally is what helps meta-programming in Elixir be a
bit sane.



*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*

On Sat, Sep 30, 2017 at 1:42 PM, <gaspa...@gmail.com> wrote:

>
>
> On Saturday, September 30, 2017 at 2:36:30 PM UTC+3, Louis Pilfold wrote:
>>
>> Heya
>>
>> You could write a library that does this rather than modifying Elixir. It
>> would be a cool project :)
>>
>> Cheers,
>> Louis
>>
>
> I wonder if I can redefine  'def' macro and inject it into every module
> without modifying module to have 'use Something' in them.
>
> /Gaspar
>
>
>
>
>>
>> On Fri, 29 Sep 2017, 18:06 , <gasp...@gmail.com> wrote:
>>
>>> Hi all!
>>>
>>> I increasingly find myself writing more or less exactly same logic as in
>>> @type/@spec in body of the function to check incoming arguments.
>>>
>>> Would it be helpful if Elixir compiler could wrap function into assert
>>> check for incoming arguments and also result generated based on typespec?
>>>
>>> I think it would be very useful for
>>>
>>> - while running unit tests immediately see where components interaction
>>> breaks
>>> - keeping unit tests data in sync while developing - creates more
>>> crashes when some stub/test data does not comply with changed logic in
>>> function
>>> - running system and checking where it breaks the contracts between
>>> components in run-time/while debugging (dyalizer does a great job to
>>> extract information during static analysis phase, but runtime can provide
>>> more incorrect data :)
>>> - encourage writing more typespecs because benefits of doing so will be
>>> visible immediately and not when (occasionally) dyalizer will be run. So
>>> make it type specification first class citizen that is not just for
>>> documenting code, but also to enforce constraints.
>>>
>>> I personally would also love to have possibility for extended typespec
>>> that would allow also specify relation between arguments too. Like
>>> assert(arg1 + arg2 > 0).
>>>
>>> It seems that it may be achieved mostly by rewriting def/defp macros and
>>> embedding asserts code generated from @spec around function body.
>>>
>>> This will slow down the execution of code and should be compiler option
>>> to turn it on/off for production/dev/testing environment separately with on
>>> setting in development/testing by default.
>>>
>>> What do you think?
>>>
>>> /Gaspar
>>>
>>> --
>>> 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/ms
>>> gid/elixir-lang-core/638bb1fe-5276-49a3-9013-a784625226ea%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/elixir-lang-core/638bb1fe-5276-49a3-9013-a784625226ea%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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/0c977fbd-d5a9-4c74-8209-
> 741b550ce43e%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/0c977fbd-d5a9-4c74-8209-741b550ce43e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAGnRm4KE0KcL_9cFP%2BrbBn7CeJ1Nf0hmvzJN-MO9ycbkLU8frQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to