HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Asking about grimoire

04-02-2007, 12:07 PM#1
MaD[Lion]
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
grim001
Quote:
Originally Posted by MaD[Lion]
I want to know if method in strucs are inline, or is method as slow as function call.
Method is just a function call

Quote:
Originally Posted by MaD[Lion]
Also i wanna ask, if i can call methods from other methods in same struct.
Yes, since they are just function calls.

Quote:
Originally Posted by MaD[Lion]
If i can, then would like to know the syntax.
struct A
method blah1...

struct B
method blah2...
call A.blah1()

Quote:
Originally Posted by MaD[Lion]
Oh one more thing, do structs support constructors?
No, you must create a fake constructor using a static method that creates the struct and does stuff with it.
04-02-2007, 06:09 PM#3
MaD[Lion]
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
Earth-Fury
Quote:
Originally Posted by MaD[Lion]
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.

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
MaD[Lion]
a tat explains :P
04-02-2007, 11:45 PM#6
Vexorian
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.