Open muzzel opened 10 years ago
Are there other examples? Maybe damage detection?
I wonder if we should allow to hook/claim any native or if we should just add two or three special cases...
I would allow them
I think hooks like they exist in vJass are (while sometimes being incredibly useful) a terrible feature as they make the code very intransparent. Only allowing selected native doesnt feel right, also there are more that only one possible application (indexing, damage detection, creating/removing objects in combination with recycling, ...) I would allow all natives to be hooked but restrikt hooks to throwing warnings instead of executing actual code.
There are many systems which provide replacements for jass natives (often wrappers for those natives) or require the user to not use certain jass natives for other reasons. A popular example are UnitIndexers which make use of the get(set)UserData natives - using these systems is risky because one cannot ensure that there are no other systems interfering with a units userdata.
In these cases a way to monitor the usage of those jass natives would be very helpful. My idea is to add a statement which hooks the native and throws a warning/error when the native is used outside of the package (inside the package it may ofc be used). The warning could either be a compiletime- or runtime warning (actually compiletime is sufficient).