WurstScript icon indicating copy to clipboard operation
WurstScript copied to clipboard

Idea: Warning/error hooks for natives.

Open muzzel opened this issue 11 years ago • 3 comments

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).

muzzel avatar Mar 14 '14 15:03 muzzel

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...

peq avatar Mar 14 '14 15:03 peq

I would allow them

menag avatar Mar 14 '14 15:03 menag

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.

muzzel avatar Mar 14 '14 16:03 muzzel