h1. New QC Syntax
+{{>toc}}
+
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.
-A clean syntax is needed, *SUGGESTIONS ARE WELCOME*, my(blub's) current suggestion is:
+A clean syntax is needed, the current implementation uses the following:
|_.definition|_.meaning|
+|<code>float foo</code>| global variable|
+|<code>float .foo</code>| entity field|
+|<code>.float foo</code>| fieldpointer|
+|<code>.float .foo</code>| entity field of type fieldpointer|
|<code>float foo(void)</code>| function|
|<code>float foo*(void)</code>| function pointer|
-|<code>.float foo(void)</code>| member: method/function pointer|
-|<code>..float foo(void)</code>|/2. member: method/function pointer returning .float|
-|<code>..*float foo(void)</code>|
-|<code>.*float foo*(void)</code>| function pointer returning .float|
-|<code>.*float</code>| fieldpointer|
-|<code>.*float foo(void)</code>| fieldpointer: method/function pointer|
-|<code>.*.float foo(void)</code>| fieldpointer: method/function pointer returning .float|
-
-Additionally, at places where the definition of members or global functions is not allowed, they will be treated like fieldpointers.
-So inside parameterlists or a functionbody the list is as follows:
-
-|_.definition|_.meaning|
-|<code>float foo(void)</code>| *function pointer*|
-|<code>float foo*(void)</code>| function pointer|
-|<code>.float foo(void)</code>| *fieldpointer: method/function pointer*|
-|<code>..float foo(void)</code>|/2. *fieldpointer: method/function pointer returning .float*|
-|<code>..*float foo(void)</code>|
-|<code>.*float foo*(void)</code>| function pointer returning .float|
-|<code>.*float</code>| fieldpointer|
-|<code>.*float foo(void)</code>| fieldpointer: method/function pointer|
-|<code>.*.float foo(void)</code>| fieldpointer: method/function pointer returning .float|
+|<code>.float foo(void)</code>| function returning a fieldpointer .float|
+|<code>.float foo*(void)</code>| function pointer, returning a fieldpointer .float|
+|<code>float .foo(void)</code>| entity field of type function returning float|
+|<code>.float .foo(void)</code>| entity field of type function returning fieldpointer|
h2. Function definitions:
To create a constant use:
<pre>const float x = 3</pre>
-h1. lda17h's suggestions
+h2. Extendable functions:
-|_.definition|_.meaning|
-|<code>float foo(void)</code>| function|
-|<code>float foo*(void)</code>| function pointer|
-|<code>float .foo(void)</code>| member function(methog). This indicates that the name foo is added to all entities (in the same way as e.g. ".float foo;" indicates that the name foo will be added to all entities) which makes more sense imho to denote member functions.. |
-|<code>.float .foo(void)</code>|/2. member: method/function pointer returning .float. (See previous comment)|
-|<code>.float foo*(void)</code>|
-|<code>.float foo*(void)</code>| function pointer returning .float|
-|<code>.float *</code>| fieldpointer|
-|<code>.float *foo*(void)</code>| fieldpointer: method/function pointer|
-|<code>.float .foo(void)</code>| fieldpointer: method/function pointer returning .float|
+Since menuQC has some funny macro: ACCUMULATE_FUNCTIONS, it seemed like a nice syntactical sugar to allow the following:
+
+<pre>float myfunc() extendable
+{
+ float mylocal = 3;
+}
+
+/* other code */
+
+float myfunc()
+{
+ mylocal += 5;
+ if (mylocal > 20)
+ return mylocal;
+}
+
+/* optionally: */
+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>