HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Whats a constant function?

05-02-2007, 06:45 PM#1
Ghost.X
I have read tutorials, but I have yet to see a definition of constant functions? What are they? How is a constant functions different from a funtion?
05-02-2007, 06:49 PM#2
PipeDream
You prepend "function" with "constant ". It puts some syntactic limitation on the function which encourages vex's optimizer to do some simplifications. It has zero effect on the runtime.
05-02-2007, 07:26 PM#3
Captain Griffen
Constant functions cannot have calls to non-constant functions, however.
05-02-2007, 07:52 PM#4
Joker
Would it be better not to use constant functions if you dont need them? (Sry for threadjacking)
05-02-2007, 08:01 PM#5
Captain Griffen
Really, constant functions are only useful when used in conjunction with Vex's optimiser for inlining.
05-02-2007, 08:50 PM#6
Vexorian
Well it is also self commenting code.
05-02-2007, 09:41 PM#7
Anopob
I've also heard that if you're giving your friend or whoever say, a JASS spell, you can use constants to make it easier for him/her to edit the values.

EDIT: Btw, is it better to just use another function to call a function that would take the place of a constant function instead of making a constant function?