This wiki is static and therefore read-only as of August 2011. More information here.
Hosted by NexuizNinjaz.com

This is an old revision of the document!


Sandbox


Use this page to test the syntax.

dev:quakec


Because dokuwiki has NO TALK PAGE and I didn't want to edit quakec article directly:

  • float .field is the same as float *pointer_to_float in c, while self.field is self→field in c, where self is structure and field is its member

Therefore, doing this:

.float field1;
.float field2;
.float field3;
.float field4;
field1 = field2;  // points to the same float
self.field1 = 8;  // self.field2 is also 8
self.field3 = 66; 
self.field4 = self.field2; // self.field4 is 8
self.field4 = self.field3; // self.field4 is 66, self.field3 is 66, self.field2 and self.field1 have values of 8


it is not clear whether the space for float pointed from field1 was allocated during pointer declaration or not and whether quakecVM does some sort of garbage collecting. If not, it should be mentioned that programming like previous example is bad habit cause it will leak memory;

  • it should be mentioned that startpos should be 0 in substring if you want to search whole string and that generally strings are indexed from 0 upwards (no negative length, etc...);
  • can't see the difference between n fields and field of array type, which has n elements (both are accessed the same e.(array[index])) If there is difference, an explanation would be useful;
  • pointers to functions chapter is confusing. Which way is the general way? Separate var keyword explanation could be useful. As well, that original quakec didn't have neither typedef nor var and that fteqcc has a const keyword to separate variables from constants.


---

There is no such thing as “allocation” of fields. They are fixed, and “allocated” by the compiler.

Substring - add that if you want, but this page is not meant to explain all the functions. This should be in the extensions.qh file.

.float field1 declares NO VARIABLE, if used globally, but a field allocated by the compiler. “field1 = field2” should be an error, and if not, that's another bug of the compiler to fix.

var .float field1 would declare what you have used. And there is a separate var keyword explanation, explaining that the keyword is used to force it to be a variable declaration if it would be ambiguous.

And as for const - yes, that is obvious, but the Nexuiz code base does not use it (too many original QuakeC coders...).

 
playground/playground.1224945522.txt.gz · Last modified: 2008/10/25 16:38 by 84.58.33.195
Nexuiz Ninjaz Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
GFDL logoGFDLcontent Unless mentioned on the licensing page, the work on this page is licensed under the GNU Free Documentation License. The author states that the text and images can be used within the restrictions of this license (for example, they can be incorporated into certain free encyclopedias such as Wikipedia).
Kindly hosted by NexuizNinjaz.com