]> de.git.xonotic.org Git - xonotic/xonotic.wiki.git/blobdiff - NewQC.textile
(Commit created by redmine exporter script from page "Art_Roadmap" version 40)
[xonotic/xonotic.wiki.git] / NewQC.textile
index 0245340ba10071299000278d701ae2557ef47e88..0e6baef103b8815e0bccb89d9dc4a87358e9bced 100644 (file)
@@ -2,6 +2,8 @@ h1. New QC Syntax
 
 It is possible that at some point we decide to switch QC-compiler which requires some changes to the code.
 
+*For more information see* http://dev.xonotic.org/projects/bocc
+
 h2. Clean syntax:
 
 In fteqcc there are some ambiguities regarding fieldpointers, function pointers, and field-return-types etc.
@@ -59,3 +61,23 @@ float myfunc() final
     return 3;
 }
 </pre>
+
+h2. Variadic parameters (do not use yet)
+
+(This might get changed to be more flexible so do not rely on this syntax...)
+
+Another "enhancement" is the possibility to have functions with variadic parameter lists. However, the only way to sanely access them (until pointers are allowed) is via a recursive way.
+Here's an example that assumes float parameters and prints them one after the other:
+<pre>void printfloats(float count, float first, ...)
+{
+    if (count <= 0) // if there are no parameters, return
+        return;
+    if (count == 1) { // If there's one parameter, print it, plus a new-line
+        print(strcat(ftos(first), "\n"));
+        return;
+    }
+    // Otherwise we have multiple parameters left, so print the float, and add a comma
+    print(strcat(ftos(first), ", "));
+    myprint(count-1, ...);
+}</pre>
+So <code>myprint(4, 1, 2, 3, 4)</code> would print <code>"1, 2, 3, 4\n"</code>