I'm an Erlang beginer and I'd like to find a way to list all the methods available for a given module. What's the best way?
In my case, the module is ejabberd_odbc.
You can call Modulename:module_info() to get information on the module in a proplist form. To get exports only, call Modulename:module_info(exports).
I'm always checking the exports section in the source of the module.
There is a tool you can install called edoc, whose manual is at: http://www.erlang.org/doc/man/edoc.html This allows javadoc style documentation to be generated for Erlang modules.
Also there is ejabberd_odbc documentation at: http://www.process-one.net/docs/ejabberd/devdoc/trunk/ejabberd_odbc.html
Related
I have a WPF application built on top of PRISM.
When i tries to list module before loaded modules when find modules,I use dicitonary find module,but i dont look any module in modulecategory.
Any suggestions on how I can do this?
Thanks in advance
The easiest thing to do is to name your module assemblies in a special way, like MySomething.module.dll and then look for these when putting together the module catalog. There once was a module catalog implementation around on codeplex that allowed to pass a search pattern including subfolders... link
In my work, we have a file with utilities functions that are extended in _.mixin() function at runtime. No, I cannot change the framework, because the solution would be to separate those function from _.mixin() and make them and indepent module, that would be the best.
Either way, my problem is that I cannot link this file, with all the extended functions in WebStorm, so I always see Unresolved function or method warning
Yes I have tried to add the file in the Library tab under Libraries & Framework preferences. And it did nothing.
So my question is, It is possible to WebStorm (or other Atlassian software) to link a file with several functions that will be extended with Underscore.js _.mixin() function to show up in Autocomplete?
Thanks, in advance
Adding the file to JavaScript libraries won't help here. _.mixin() dynamically adds passed utility functions to _ object, it's not possible to resolve such dynamically generated stuff during static code analysis unless a special treatment for the certain functions is provided. And WebStorm doesn't provide any special support for _.mixin().
If you miss it, please feel free to create a feature request in youtrack, https://youtrack.jetbrains.com/issues/WEB
I've created a Module inside the lib/, more specifically lib/my_namespace/test_module.exs.
This is all that is defined within it:
defmodule MyNamespace.TestModule do
def test do
"This is a test"
end
end
Calling the test() function of this module within a Phoenix Controller renders an error.
** (UndefinedFunctionError) function MyNamespace.TestModule.test/0 is undefined (module MyNamespace.TestModule is not available)
MyNamespace.TestModule.test()
According to the Elixir 1.2.0 Changelog, it is my understanding that Elixir is meant to reload the code in lib/ directory, so my assumption is that I wasn't going to need to do anything else.
I'm obviously wrong, and my own research hasn't been yielding anything promising. The only thing I've gathered is that my module isn't getting onto the ?loadpath? and I'm not to sure what to change so it is on the loadpath.
Could someone lend a hand and also point me in the direction of what documentation I should be reading?
Thanks in advance.
.exs files are meant for scripting and are not compiled to bytecode by mix along with the rest of the project. You should rename lib/my_namespace/test_module.exs to lib/my_namespace/test_module.ex if you want to be able to access modules defined in it from your application.
Is there a way to export all symbols in a Julia module (something like the semantic counterpart to importall)? Such a functionality would be very useful when the number of symbols to be exported grows large. TIA.
There's the Reexport.jl package that provides a form of this; it's use case is when you have a submodule and you want to reexport all of the exported symbols from the inner module into your current module. I know, not exportall, but part of the functionality.
I wrote a minimal ExportAll.jl package. It works and is tested for Julia 1.1.1 and it is available as a Julia package. Basically, it exports all symbols(!) defined in a module that is not part of any of the core modules. Disclaimer doing things like this is not good practice and should only be done with great care.
Is there a way to open a module in Erlang and then call its functions without using module name prefix?
Like opening an ML structure!
You can use
-import(my_module, [foo/1,bar/2]).
to import individual functions (in my example foo/1 and bar/2) from another module (my_module), see the modules documentation . There is no way of importing all functions from a module, they have to be explicitly listed.
Also see In Erlang how can I import all functions from a module? for an explanation why you shouldn't import functions!
No, you can't! The methods given by #johlo and #stemm are just work-arounds which allow you to not explicitly write the module name but that is all. The -import(...) declaration is a misnomer and doesn't do what you would expect.
Given Erlang's very dynamic handling of code it would be practically meaningless as well. There is no guarantee that at run-time you have the same "other" module as you had at compile-time, or if it is there at all. All code handling, compiling/loading/purging/reloading/etc. , is done on a module basis and there are no inter-module dependencies or optimisations.
Instead of import you can use defining:
-define(SIN(X), math:sin(X)).
my_func(X) -> ?SIN(X).