Page 1 of 1
coding: superload v overload
Posted: Tue Feb 10, 2015 7:33 pm
by IejirIsk
the title says most of it... but if i understanding, superload takes a single (or multiple) functions and replaces them entirely, and overload is the full file?
Re: coding: superload v overload
Posted: Tue Feb 10, 2015 9:21 pm
by 0player
Yes, more or less. With superload, you get the class that was loaded originally (or modified by higher priority addons) and can modify it programmatically. With overload, you just replace the file.
Re: coding: superload v overload
Posted: Wed Feb 11, 2015 2:26 am
by stinkstink
It's worth noting for novices that superloading also allows you to prepend/append things to a function instead of overwriting it completely, which is usually what you want to do to avoid compatibility conflicts (as well as making it easier to keep updated)
Re: coding: superload v overload
Posted: Wed Feb 11, 2015 3:41 am
by IejirIsk
stinkstink wrote:It's worth noting for novices that superloading also allows you to prepend/append things to a function instead of overwriting it completely, which is usually what you want to do to avoid compatibility conflicts (as well as making it easier to keep updated)
well, okay... the wiki mentioned that... but the example wasn't really clear for this old guy...
basically wanting to make a minor (like 1 or 2 line) change to :onHeal. ... or i guess technically, vile-life.
Re: coding: superload v overload
Posted: Wed Feb 11, 2015 2:17 pm
by Marson
There are times when a prepend/append won't do the trick and you need to actually modify the function's internal code. I've run into this a lot for UI changes. In that case you need to overwrite the entire function.