Exceedingly true yeah, tagging data is always best. On Thursday, July 21, 2016 at 12:52:19 PM UTC-6, José Valim wrote: > > Code.ensure_loaded? will load the module if one os available. However I > would strongly suggest to stop guessing and keep atoms and modules apart, > maybe by passing a tuple. Otherwise, what if you want to pass an atom and > it happens to have the same name as an Erlang module? > > On Thursday, July 21, 2016, OvermindDL1 <[email protected] <javascript:>> > wrote: > >> Confirmed it is what I thought it was: >> ```elixir >> iex(16)> :erlang.function_exported(:observer, :module_info, 0) >> false >> iex(17)> :observer.start >> :ok >> iex(18)> :erlang.function_exported(:observer, :module_info, 0) >> true >> ``` >> >> On Thursday, July 21, 2016 at 12:41:18 PM UTC-6, OvermindDL1 wrote: >>> >>> Oh, and I might know why, the module might not be loaded yet. Until >>> code is actually called in the module then it is not loaded into the VM, >>> but once loaded it stays loaded, I actually have something that manages >>> that in my Plugin system that handles dynamic Module detection and loading: >>> ```elixir >>> iex(14)> ExPlugins.get_plugins(MyServer.PermsBehaviour) >>> [MyServer.Perms.Auth.Permission, MyServer.Perms.Auth.Profile, >>> MyServer.Perms.Auth.Users, MyServer.Perms.Auth, >>> MyServer.Perms.Help.Issue, >>> MyServer.Perms.Help, MyServer.Perms.Messenger, >>> MyServer.Perms.SomeOtherSection.Report, >>> MyServer.Perms.SomeOtherSection.Requirement, >>> MyServer.Perms.SomeOtherSection.Semester, >>> MyServer.Perms.SomeOtherSection.Student.Requirement, >>> MyServer.Perms.SomeOtherSection.Student.Semester, >>> MyServer.Perms.SomeOtherSection.Student, >>> MyServer.Perms.SomeOtherSection, MyServer.Perms.Tag] >>> ``` >>> It is my Elixir port of my old Erlang plugin system (so much easier to >>> write here). It detects what module implement a behaviour, verify they are >>> loaded into the system, if not it loads them, then returns a list of them >>> (while caching the results for faster response later along with being able >>> to purge the cache via `ExPlugin.clear_cache(MyServer.PermsBehaviour)` or >>> just `ExPlugin.clear_cache()` to clear everything. But yes, I had to load >>> the modules properly to detect their information. >>> >>> On Thursday, July 21, 2016 at 12:32:43 PM UTC-6, OvermindDL1 wrote: >>>> >>>> Nope, something is borked for you: >>>> ```elixir >>>> iex(12)> :erlang.function_exported(GenEvent.Stream, :module_info, 0) >>>> true >>>> ``` >>>> >>>> On Thursday, July 21, 2016 at 12:28:28 PM UTC-6, Theron Boerner wrote: >>>>> >>>>> True, OvermindDL1's is the way to go unless you need info about the >>>>> module. Anyone know why this doesn't work?: >>>>> >>>>> iex(11)> :erlang.function_exported(GenEvent.Stream, :module_info, 0) >>>>> false >>>>> >>>>> or >>>>> >>>>> iex(1)> :erlang.get_module_info(GenEvent.Stream, :module) >>>>> ** (ArgumentError) argument error >>>>> :erlang.get_module_info(GenEvent.Stream, :module) >>>>> >>>>> Could it be because it defined a struct? >>>>> >>>>> On Thu, Jul 21, 2016 at 1:20 PM OvermindDL1 <[email protected]> >>>>> wrote: >>>>> >>>>>> That requires dealing with an error and having a try/catch and it is >>>>>> just a pain. As I mentioned before, testing if the function >>>>>> `module_info/0` exists I think is a great way: >>>>>> ```elixir >>>>>> iex(9)> :erlang.function_exported(:blah, :module_info, 0) >>>>>> false >>>>>> iex(10)> :erlang.function_exported(String, :module_info, 0) >>>>>> true >>>>>> ``` >>>>>> >>>>>> >>>>>> On Thursday, July 21, 2016 at 12:14:30 PM UTC-6, Theron Boerner wrote: >>>>>>> >>>>>>> Use this: >>>>>>> >>>>>>> iex(7)> :erlang.get_module_info(String, :module) >>>>>>> String >>>>>>> iex(8)> :erlang.get_module_info(:lists, :module) >>>>>>> :lists >>>>>>> iex(9)> :erlang.get_module_info(:walrus, :module) >>>>>>> ** (ArgumentError) argument error >>>>>>> :erlang.get_module_info(:walrus, :module) >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Thursday, July 21, 2016 at 12:20:46 PM UTC-5, ...Paul wrote: >>>>>>>> >>>>>>>> Not saying this is a great idea, but I'm working with a pattern >>>>>>>> where a parameter can be a module or a string. The gist is: >>>>>>>> >>>>>>>> def do_it(data, foo) when is_bitstring(foo), do: data >>>>>>>> def do_it(data, foo) do >>>>>>>> foo.do_other_thing(data) >>>>>>>> end >>>>>>>> >>>>>>>> Works great, but what if I want to allow actual atoms to be used, >>>>>>>> similar to strings? How can I identify the difference between an >>>>>>>> actual >>>>>>>> atom, like :bar, and a module, like Bar? >>>>>>>> >>>>>>>> is_atom() returns true for both cases (makes sense because module >>>>>>>> names are basically atoms, :"Elixir.Bar") Is there a way to tell the >>>>>>>> difference with a guard? >>>>>>>> >>>>>>>> If not a guard, some Kernel or Module function? >>>>>>>> >>>>>>>> ...Paul >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "elixir-lang-talk" 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-talk/9fed8269-f58f-4d65-b369-ea6477b2126a%40googlegroups.com >>>>>> >>>>>> <https://groups.google.com/d/msgid/elixir-lang-talk/9fed8269-f58f-4d65-b369-ea6477b2126a%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-talk" 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-talk/ea35fb1e-a2b6-4029-9425-ea71d265ee24%40googlegroups.com >> >> <https://groups.google.com/d/msgid/elixir-lang-talk/ea35fb1e-a2b6-4029-9425-ea71d265ee24%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > > > *José Valim* > www.plataformatec.com.br > Skype: jv.ptec > Founder and Director of R&D > >
-- You received this message because you are subscribed to the Google Groups "elixir-lang-talk" 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-talk/bc8cfd34-ba1f-41b8-8b7b-725424cd6bb7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
