ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new:multiple_return_values

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
new:multiple_return_values [2018/02/19 12:54] korshunnew:multiple_return_values [2019/04/19 21:18] (current) – removed korshun
Line 1: Line 1:
-====== Multiple return values ====== 
- 
-ACSUtils uses a simple convention for functions returning multiple values, like ''RotateVector'': 
- 
-There are global variables r1 through r8. The functions write their return values to them. 
- 
-    RotateVector(x, y, angle); // Call the function 
-    int newX = r1; // Get the first returned value 
-    int newY = r2; // And the second one 
- 
-<note warning> 
-You should retrieve the return values **as soon as possible**, or else they may get overwritten by other functions that return multiple values. 
- 
-Don't do this: 
-<code> 
-SomeFunctionWithMultipleReturns(...); 
-SomeOtherFunction(r1); 
-int b = r2; 
-</code> 
-Because ''SomeOtherFunction'' may call functions that **overwrite r2**! Instead, strictly follow this style: 
- 
-<code> 
-SomeFunctionWithMultipleReturns(...); 
-int a = r1; 
-int b = r2; 
- 
-SomeOtherFunction(a); 
-</code> 
-</note> 
  
new/multiple_return_values.1519037649.txt.gz · Last modified: 2018/02/19 12:54 by korshun