HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Static Methods and Private Functions

02-08-2009, 10:11 AM#1
wraith
When I look over to the vJass spell section , most of the spells core area are done using the satic methods instead of private functions. Can anyone tell me why do people use static methods instead of private function and then setting the struct stuffs.
02-08-2009, 11:00 AM#2
Skater
They think its nicer and sometimes its just make sense to put everything into a struct...
02-08-2009, 11:02 AM#3
peq
Those methods are not really static, its just a kind of workaround for not beeing allowed to use a non static method as a callback-function.

So people use static methods and
Collapse JASS:
local structname this = structname(GetAttachedIntegerSomehow())
to bind the static method to an specific instance of the struct, so its not really static anymore and you can use the short dot Syntax to access struct members.
02-08-2009, 11:39 AM#4
DioD
Just check output code...
02-08-2009, 02:19 PM#5
Zerzax
I think using static methods instead of functions is cleaner. It's an organized way of looking at the struct: the spell script is now an extension of the struct rather than the struct being an extension of the spell. That sounds weird, but it's personal preference, really.