after searching, I couldn't find how to get the type of parameters in an erlang module. For more clear, this is what I'm trying to do:
erlang:loaded()
-> this returns a list of atoms which are modules names Module:module_info(exports)
-> this returns a list of tuples which are likely this: {function_name, number_of_parameters) An example:
application:load("1", 2, "3", {123, "2\\"{[1234", 123}, ad, <<"asa]}\\">>\\", 2, 300:16>>).
Output:
Param lists:
"1" ---> type: string
2 ---> type: integer
"3" ---> type: string
{123, "2\\"{[1234", 123}
---> type: tuple` ad ---> type: atom
<<"asa]}\\">>\\", 2, 300:16>> ---> type: binary
my problem was solved at this: erlang parse string to data types using regex
I'm not aware that this is possible, the way you describe parameters in Erlang is using spec annotations in your code, but not all the code out there is well documented and using specs like:
-spec Module:Function(ArgType1, ..., ArgTypeN) -> ReturnType.
Also, a function can take different argument types and use guards for different handling of the input. Or even use syntactic sugar on records to create custom types or use any()
. Dialyzer is the only thing that can help, perhaps checking dialyzer:plt_info(Plt)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.