overloading of methods
Sun Apr 12 16:50:23 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* overloading of methods
diff -rN -u old-doc/qt.docbook new-doc/qt.docbook
--- old-doc/qt.docbook 2014-10-30 06:55:33.000000000 +0100
+++ new-doc/qt.docbook 2014-10-30 06:55:33.000000000 +0100
@@ -23,7 +23,7 @@
the unit tests and <package>:qt.examples</package> for various examples.
</para>
-<section><title>QApplication</title>
+<section><title>qt:application</title>
<para>
The <classname>qt:application</classname> object should created with:
<macro>qt:with-app</macro>. In its body the event loop can be
diff -rN -u old-doc/smoke.docbook new-doc/smoke.docbook
--- old-doc/smoke.docbook 2014-10-30 06:55:33.000000000 +0100
+++ new-doc/smoke.docbook 2014-10-30 06:55:33.000000000 +0100
@@ -46,8 +46,7 @@
<section><title>Methods</title>
<para>
-The C++ methods are generic functions in the <code>:cxx</code> package.
-Their lambda list is: <code>(object &amp;rest args)</code>.
+C++ methods are generic functions in the <code>:cxx</code> package.
</para>
<para>
The C++ method call: <code>myInstance->frob(1);</code> is in Lisp:
@@ -60,6 +59,24 @@
adding methods. <code>:around</code>, <code>:before</code>, <code>:after</code>
and <code>(call-next-method)</code> are supported.
</para>
+<informalexample>
+<programlisting>(defclass the-object-does-nothing (<classname>qt:object</classname>)
+ ()
+ (:metaclass <classname>cxx:class</classname>))
+
+(defmethod cxx:timer-event ((object the-object-does-nothing) event)
+ (declare (ignore object event))
+ (call-next-method))
+</programlisting>
+</informalexample>
+<para>
+<package>:cxx</package> generic functions can be overload by argument count. Lambda list
+keywords (e.g.: <code>&amp;rest</code> and <code>&amp;key</code>) are not supported.
+</para>
+<note><para>
+Make sure you have the right number of arguments when adding a method; otherwise it will
+not be called.
+</para></note>
</section>
<section><title>Static Methods</title>
@@ -96,8 +113,9 @@
their deletion. When a <classname>qt:object</classname> has a parent, a strong
reference is kept to prevent its garbage collection until the parent is deleted.
</para>
+<caution>
<para>
-Not that an instance may depend on an other one.
+An instance may depend on an other one.
It is a bad idea to do something like this:
<programlisting>
(defvar *meta* (cxx:meta-object (make-instance 'qt:object)))
@@ -107,6 +125,7 @@
be garbage collected, and then the <code>QMetaObject</code> instance is deleted along
with the <code>QObject</code>.
</para>
+</caution>
</section>
</chapter>