aboutsummaryrefslogtreecommitdiffstats
path: root/system/doc/reference_manual/macros.xml
AgeCommit message (Collapse)Author
2018-05-24Update copyright yearHenrik Nord
2018-05-09macros.xml: Document ?OTP_RELEASE, -if and -elifTomas Abrahamsson
2017-05-04Update copyright yearRaimo Niskanen
2017-01-11macros.xml: Remove a reference to OTP R7Björn Gustavsson
2016-12-07Update copyright-yearErlang/OTP
2016-05-04Add documentationBjörn Gustavsson
2016-02-17Implement ?FUNCTION_NAME and ?FUNCTION_ARITY macrosBjörn Gustavsson
For a long time, users have asked for one or more macros that would return the name and arity of the current function. We could define a single ?FUNCTION macro that would return a {Name,Arity} tuple. However, to access just the name or just the arity for the function, element/2 must be used. That would limit its usefulness, because element/2 is not allowed in all contexts. Therefore, it seems that we will need two macros. ?FUNCTION_NAME that expands to the name of the current function and ?FUNCTION_ARITY that expands to arity of the current function. Converting the function name to a string can be done like this: f() -> atom_to_list(?FUNCTION_NAME) ++ "/" ++ integer_to_list(?FUNCTION_ARITY). f/0 will return "f/0". The BEAM compiler will evaluate the entire expression at compile-time, so there will not be any run-time penalty for the function calls. The implementation is non-trivial because the preprocessor is run before the parser. One way to implement the macros would be to replace them with some placeholder and then let the parser or possibly a later pass replace the placeholder with correct value. That could potentially slow down the compiler and cause incompatibilities for parse transforms. Another way is to let the preprocessor do the whole job. That means that the preprocessor will have to scan the function head to find out the name and arity. The scanning of the function head can be delayed until the first occurrence of a ?FUNCTION_NAME or ?FUNCTION_ARITY. I have chosen the second way because it seems less likely to cause weird compatibility problems.
2015-06-18Change license text to APLv2Bruce Yinhe
2015-03-12Update Erlang Reference ManualHans Bolinder
Language cleaned up by the technical writers xsipewe and tmanevik from Combitech. Proofreading and corrections by Hans Bolinder.
2013-04-19Convert XML files to UTF-8Hans Bolinder
2011-12-09Update copyright yearsBjörn-Egil Dahlberg
2011-11-09Fix typo in the Reference Manual macros sectionRicardo Catalinas Jiménez
The module is not added in a function call inside a macro.
2010-02-01documentation: Macros overloading partly rewrittenHans Bolinder
2010-02-01update the documentation on preprocessor in the reference manualChristopher Faulet
New section added on Macros Overloading
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP