wurstscript / WurstScript

Programming language and toolkit to create Warcraft III Maps
https://wurstlang.org
Apache License 2.0
225 stars 30 forks source link

Idea: Warning/error hooks for natives. #222

Open muzzel opened 10 years ago

muzzel commented 10 years ago

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

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

menag commented 10 years ago

I would allow them

muzzel commented 10 years ago

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.