--
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/57e4a930-f4f2-4efa-a0bf-35f470a652a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wiadomość napisana przez Louis Pilfold <lo...@lpil.uk> w dniu 08.04.2019, o godz. 10:39:
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/d9ZjViQaOY8/unsubscribe.
To unsubscribe from this group and all its topics, 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/CABu8xFBrM7LuJoZT0HzPQ-ifxOSgVZT03XwRu%3D-pC%3DQ%3D5Ow21Q%40mail.gmail.com.
defmodule X do
def foo, do: " hello"
defmacro xpto, do: "Hey"
end
defmodule Y do
import X
#require X
#def bar, do: X.xpto() <> X.foo() <> " world"
end
You do not need to use macro to require compilation. You can use function or even just depending on fact that this module is already compiled in some highly hacky code with metaprogramming. I cannot give you any reasonable example right now. Also remember that you can require something just to call functions during compile time, it do not need to be macro.
Wiadomość napisana przez Louis Pilfold <lo...@lpil.uk> w dniu 08.04.2019, o godz. 10:39:
HeyWouldn't it be possible to track if any macros have been used by the requiring module? I'm not familiar with the compiler here but it seems like it is always possible as all information is available at compile time.Cheers,Louis
On Mon, 8 Apr 2019, 09:19 Łukasz Niemier, <luk...@niemier.pl> wrote:
Not possible as `require`s are always used - by the compiler, as this marks that required module need to be compiled before compilation of module with require.
W dniu piątek, 5 kwietnia 2019 17:48:56 UTC+2 użytkownik Mário Guimarães napisał:Hi,I suggest for Elixir to warn on unused requires, like it does for unused aliases.Thanks--
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-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/57e4a930-f4f2-4efa-a0bf-35f470a652a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/d9ZjViQaOY8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-l...@googlegroups.com.
Wiadomość napisana przez Mário Guimarães <mario.luis...@gmail.com> w dniu 08.04.2019, o godz. 11:22:
To unsubscribe from this group and all its topics, 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/130d4573-9194-4d91-be5b-c2ed909f2001%40googlegroups.com.
The problem is that `import` does more, and you can detect that `import` is unused and it can be replaced by `require`, but compiler cannot reason that `require` is unneeded as for example imagine that we have 2 modules (in separate files, as this will not work within single file):defmodule A dodef foo, do: 10endAnd in second filedefmodule AllFoos dorequire A@foos for module <- :code.all_loaded(), function_exported?(module, :foo, 0), do: moduledef foos, do: @foosendAnd without that `require` this code will depend on compilation order (which isn’t guaranteed by Elixir compiler) to work properly. So as you can see the compiler has no knowledge whether it can alter compilation order restricted by user.Of course this is highly unlike scenario for `require`, but is perfectly valid code right now, with very well defined behaviour.
Wiadomość napisana przez Mário Guimarães <mario.lui...@gmail.com> w dniu 08.04.2019, o godz. 11:22:
To unsubscribe from this group and all its topics, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/BAFBD690-D982-4C1E-9873-B7F3709D4D62%40niemier.pl.
HeyIt's not necessary to call require in order to call functions from another module at compile time, so we can remove or warn if only functions are used.What type of metaprogramming needs require but does not use macros? I thought that if no macros were used then a require can be safely removed.Cheers,Louis
On Mon, 8 Apr 2019, 09:45 Łukasz Niemier, <luk...@niemier.pl> wrote:
You do not need to use macro to require compilation. You can use function or even just depending on fact that this module is already compiled in some highly hacky code with metaprogramming. I cannot give you any reasonable example right now. Also remember that you can require something just to call functions during compile time, it do not need to be macro.
Wiadomość napisana przez Louis Pilfold <lo...@lpil.uk> w dniu 08.04.2019, o godz. 10:39:
HeyWouldn't it be possible to track if any macros have been used by the requiring module? I'm not familiar with the compiler here but it seems like it is always possible as all information is available at compile time.Cheers,Louis
On Mon, 8 Apr 2019, 09:19 Łukasz Niemier, <luk...@niemier.pl> wrote:
Not possible as `require`s are always used - by the compiler, as this marks that required module need to be compiled before compilation of module with require.
W dniu piątek, 5 kwietnia 2019 17:48:56 UTC+2 użytkownik Mário Guimarães napisał:Hi,I suggest for Elixir to warn on unused requires, like it does for unused aliases.Thanks--
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-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/57e4a930-f4f2-4efa-a0bf-35f470a652a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/d9ZjViQaOY8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-l...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CABu8xFBrM7LuJoZT0HzPQ-ifxOSgVZT03XwRu%3D-pC%3DQ%3D5Ow21Q%40mail.gmail.com.
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-l...@googlegroups.com.
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/0b5053f9-17a7-4b1c-ab62-4879923fcddc%40googlegroups.com.
For note, I use `require` to compile another module that then generates 'other' things that are then used by the module that is calling require (calls another language build system), so it has non-macro uses.
--
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/CAM%3DYcdhet%3D3U73L0RBHQQUqTCw%3DfQuQkASQyTHfm4zEU9p90fw%40mail.gmail.com.
Hello all,
I’d like to revisit this topic after some years. Back in 2019 there was agreement that a warning for unused require could make sense, but more investigation was needed because of its dual role (ensuring compilation + enabling macros).
Has the stance on this changed since then?
Would adding a warning when no macros are used from a required module be considered today?
Thanks!
To view this discussion visit https://groups.google.com/d/msgid/elixir-lang-core/d7f98e5c-f28a-49b3-b2ae-9aa0d7266b09n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BfJ4jKNWvhzC7MiuUjUr6_5vpfeEuBs1%3DSAv3bo1Oxrw%40mail.gmail.com.