Thread Tools Display Modes
08/05/15, 02:33 PM   #1
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
[outdated] Please add a type check to zo_callLater

Lua Code:
  1. function zo_callLater(func, ms)
  2.     assert(type(func) == "function")

It's so easy to mistype a function name, and all you get is a "function expected instead of nil" X seconds LATER with useless stack trace.
Technically table or userdata may also be called, but there are good reasons not to allow them in zo_callLater:
  1. checking for the presence of the __call metamethod at the time of zo_callLater is pointless, because it can appear/disappear before LATER
  2. if there's no __call metamethod LATER, you'll get something like "object cannot be called" error with useless stack trace, and you're left with no hint as to where the error comes from

---

While you're at it, please also change the deferred function to
Lua Code:
  1. function()
  2.     EVENT_MANAGER:UnregisterForUpdate(name)
  3.     func(id)
  4. end)

i.e. unregister BEFORE you call func. It has already been requested some time ago. Currently it's the other way round, and if func throws an error, it isn't unregistered and keeps being called and spitting errors indefinitely.
 
08/05/15, 06:31 PM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
I second the second request. This issue has driven me to use my own version of zo_callLater for private use...
 

ESOUI » Developer Discussions » Wish List » [outdated] Please add a type check to zo_callLater


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off