lep / jassdoc

Document the WarCraft 3 API
52 stars 20 forks source link

Boolexpr API: Describe handle edge-cases, add See refs #113

Closed Luashine closed 10 months ago

Luashine commented 10 months ago

Test code:

https://github.com/Luashine/wc3-test-maps/blob/3c52ea0994efa6f4f6e9c294ff616955f6a91686/Boolean-expression-API/README.md

In particular this paragraph rewritten:

(EDIT: dear @note I am sorry for pinging you again LOL)

@note Lua: Always returns a new handle unless the passed parameter is nil, in this case it MAY return the same handle depending on unknown conditions (consecutive calls are likely to reuse previous handle).

Jass: Returns same handle when creating multiple filters for the same function: Filter(function foo) == Filter(function foo) ("foo" can be non-constant and constant).

For this reason, do not destroy filterfuncs created with Filter in Jass, in the best case it does nothing but in the worst case it would affect some internals.

This behavior is similar to Condition.

Lua: It's a surprise to me that the handling of handles is so inconsistent here. Maybe it's entirely related to GC but for unknown reasons it does not return the same handle when given a global function in Lua.

lep commented 10 months ago

I guess the lua stuff make sense in the context of closures etc. Thanks.