aboutsummaryrefslogtreecommitdiffstats
path: root/system/doc/reference_manual/macros.xml
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2010-02-02 14:22:37 +0000
committerErlang/OTP <[email protected]>2010-02-02 14:22:37 +0000
commit085012b1ac9251d1cbd821f8b28034072fba63c3 (patch)
treeddc08c9ff5bce8cc8f7881300316d774fb006fba /system/doc/reference_manual/macros.xml
parentf91fcac6739141af4bb66a97dfdaaccdcd74f50b (diff)
parent1ab56cb24a8a037d61076314230839fdcc325d7d (diff)
downloadotp-085012b1ac9251d1cbd821f8b28034072fba63c3.tar.gz
otp-085012b1ac9251d1cbd821f8b28034072fba63c3.tar.bz2
otp-085012b1ac9251d1cbd821f8b28034072fba63c3.zip
Merge branch 'cf/epp-macro-overloading' into ccase/r13b04_dev
* cf/epp-macro-overloading: yecc_SUITE: Adjustment for modified error tuple epp_SUITE: Increase code coverage Minor corrections and clean-ups documentation: Macros overloading partly rewritten update the documentation on preprocessor in the reference manual epp: change rules to choose the right version of a macro epp: Add support of macros overloading epp: fix bug in the function scan_undef OTP-8388 Macros overloading has been implemented. (Thanks to Christopher Faulet.)
Diffstat (limited to 'system/doc/reference_manual/macros.xml')
-rw-r--r--system/doc/reference_manual/macros.xml38
1 files changed, 35 insertions, 3 deletions
diff --git a/system/doc/reference_manual/macros.xml b/system/doc/reference_manual/macros.xml
index a1ba182eff..9dd5fc79bd 100644
--- a/system/doc/reference_manual/macros.xml
+++ b/system/doc/reference_manual/macros.xml
@@ -4,7 +4,7 @@
<chapter>
<header>
<copyright>
- <year>2003</year><year>2009</year>
+ <year>2003</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>The Preprocessor</title>
@@ -140,6 +140,38 @@ bar(X) ->
</section>
<section>
+ <title>Macros Overloading</title>
+ <p>It is possible to overload macros, except for predefined
+ macros. An overloaded macro has more than one definition,
+ each with a different number of arguments.</p>
+ <p>The feature was added in Erlang 5.7.5/OTP R13B04.</p>
+ <p>A macro <c>?Func(Arg1,...,ArgN)</c> with a (possibly empty)
+ list of arguments results in an error message if there is at
+ least one definition of <c>Func</c> with arguments, but none
+ with N arguments.</p>
+ <p>Assuming these definitions:</p>
+ <code type="none">
+-define(F0(), c).
+-define(F1(A), A).
+-define(C, m:f).</code>
+ <p>the following will not work:</p>
+ <code type="none">
+f0() ->
+ ?F0. % No, an empty list of arguments expected.
+
+f1(A) ->
+ ?F1(A, A). % No, exactly one argument expected.</code>
+ <p>On the other hand,</p>
+ <code>
+f() ->
+ ?C().</code>
+ <p>will expand to</p>
+ <code>
+f() ->
+ m:f().</code>
+ </section>
+
+ <section>
<title>Flow Control in Macros</title>
<p>The following macro directives are supplied:</p>
<taglist>