| 05-26-2006, 11:59 AM | #1 |
Is there any? ... |
| 05-26-2006, 12:26 PM | #2 |
Yes. Functions, with the inbuilt ones often refered to as 'BJs', are most of the time completely pointless, such as simply swapping around the input, and thus should not be used when working directly in JASS, as it is a pointless waste of time, taking up processing time and memory. In a high level programming language, this is a bad thing. |
| 05-26-2006, 01:19 PM | #3 |
Hmm, but what about those functions which do not have the inputs swapped? Like they would only have "BJ" as the difference, but nothing else. Also, not all BJ functions are given as "natives"... |
| 05-26-2006, 01:31 PM | #4 | |
Quote:
natives and functions, err natives are coded in the very war3.exe and functions just call the natives to work. Blizzard.j has a lot of function that only call a single native to swap arguments, they also have some other functions that might be useful but some of the bj functions have leaks and some are not well optimized. You can make your own functions but you can't make your own natives unless you hack the game or something |
| 05-26-2006, 01:42 PM | #5 |
.....................Oh................. Never knew this >_<.... |
| 05-26-2006, 06:01 PM | #6 |
Let's not speak of normal natives and functions, but lets think of this purely mathamatically. Consider the real numbers, the following operations are well defined upon it: *,+,-,/. If you despute this, please consult fields. We can call these four binary operations native Now let us consider the exponent. It is not a binary operation upon the real line. (consider (-1) raised to the 1/2 power). However, we might say we know how to raise a real number to an integer power using the following definition. Code:
x^(-n)=(1/x)*x^(1-n) x^0=1 x^n=x*x^(n-1) Using these nifty definition we could define a function. What is the domain of this function? A pair from the set Reals cross Integers. What is the codomain? The real numbers. Thus we can define expt:{(x,y)| x in Reals, y in Ints}->Real. However, we really never need to use it. We could simply always insert our relation in place of actually using expt. This is what is called syntactic sugar. That is why functions exist. You in theory never really need to define functions, and could write everything in each of the trigger blocks and never use jass. However, it is much much much easier to read thanks to syntactic sugar. |
| 05-26-2006, 06:11 PM | #7 |
Aside from your negative power definition appearing to be a bit off there, that is a pretty good way of decribing it. As in, if I'm looking at it correctly, your negative power thing there returns x^n instead of x^(-n). Using your definition of x^n: Code:
x^(-n) = 1/(x^-n) //as in, the negative in the denominator converts the negative number to positive |
| 05-26-2006, 07:09 PM | #8 |
! From what i have understood, are you saying that functions are generally slower, but better structured? |
| 05-26-2006, 07:17 PM | #9 |
no, but sometimes it can be useful to use a function instead of calling all the natives(which the function does). |
| 05-26-2006, 10:43 PM | #10 |
My mistake, but the general notion is a function is just a gift from above that adds some ease of use. Were not talking about return bug functions, or required function calls (in the case of group iteration although you can do it without If I rember correctly), were simply talking about functions as algorithm running bits of code. |
