Jass NewGen Pack features a tool known as JassHelper, it will basically provide a neat interface for you to code in. (with some nice features) For example, you don't have to go to the variable editor to create globals. You can simply declare a globals block:
JASS:
globals
unit someUnit //creates a global variable of the type "unit" with the name "someUnit"
endglobals
This is the link to Jass NewGen Pack:
http://www.wc3c.net/showthread.php?t=90999
This is the link to the latest published JassHelper (aside from Cohadar's):
http://www.wc3c.net/showthread.php?t=88142
This is the link to the readme for JassHelper, which should explain some things:
http://www.wc3c.net/vexorian/jasshelpermanual.html
---
Anyway, basically you really don't need the keyword "constant" before functions except for organizational purposes or if you don't want to allow a function return a non-constant value. (for whatever reason)
The reason why I mentioned freeform globals is because people used to use constant functions for configurable values for spells (like amount of damage). Example:
JASS:
constant function DmgAmount_LightningSpell takes nothing returns real
return 250. //edit this to change the damage of the spell...
endfunction
//... then they refer to it later on...
call UnitDamageTarget( u, tar, DmgAmount_LightningSpell(), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null )
That is how configurables for spells used to be done. (so that people could easily modify values without looking too far)
However, with JassHelper, spell configurables are usually just done like this:
JASS:
globals
constant real DamageAmount_LightningSpell = 250.
endglobals
//... then they refer to it later on...
call UnitDamageTarget( u, tar, DamageAmount_LightningSpell, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null )
Now this may present the question, why use the
constant
keyword before a configurable? It really depends on the spell, but usually you don't want configurables to have different values throughout the game. Some stuff like damage are meant to be fixed for certain spells, so you can add the constant keyword so that someone can't re-set the variable to a different value. In the example with the global DamageAmount_LightningSpell, adding the "constant" keyword makes it so that you can't reassign the value to something else later on. For example:
set DamageAmount_LightningSpell = 125.
Will throw an error since the variable has the keyword
constant
before it.
TL;DR: The keyword
constant
is mostly an organizational tool. It is up to you whether you want to use it for your code, especially if you are not submitting the code for public use.