| 04-02-2007, 12:07 PM | #1 |
I want to know if method in strucs are inline, or is method as slow as function call. Also i wanna ask, if i can call methods from other methods in same struct. If i can, then would like to know the syntax. Oh one more thing, do structs support constructors? |
| 04-02-2007, 05:09 PM | #2 | ||||
Quote:
Quote:
Quote:
method blah1... struct B method blah2... call A.blah1() Quote:
|
| 04-02-2007, 06:09 PM | #3 |
above u call A.blah1() in struct B but wat if u wanna call same method in same struct like struct A method blah1... method blah2... call A.blah1 ?? or is it kinda like this.blah1 or wat --- Hmm if methods are only functions calls, then they are a bit slow i think, would be cool if the compiler somehow put them inline in the preprocessing progress, this will make thigns faster since function call is slow. |
| 04-02-2007, 06:16 PM | #4 | |
Quote:
this. refers to the current struct. Inlining is a complex thing. For constant functions that just return a value, its easy. With functions that take paramiters and have locals, its much, much harder. The compiler would have to write valid code that does exactly what your code did. And the cost of a function call isn't so much. Except in extream cases, where you may want to re-consider using structs, in favour of a more low-level approach. |
| 04-02-2007, 06:52 PM | #5 |
a tat explains :P |
| 04-02-2007, 11:45 PM | #6 |
ahaha. It would be 'cool' But it is a heck of a thing to do autmatic inlining that is at the same time cool and useful. I am also unable to think of a situation in which method inlining is actually useful unless you make methods just for the heck of it. And this thread is not really about grimoire. |
