Closure scoping - read this post a while back abou...
# lucee
a
Closure scoping - read this post a while back about the importance of scoping closures https://dev.lucee.org/t/query-of-query-vs-queryfilter/5747/7 and Zach's example he added in the docs - https://docs.lucee.org/guides/cookbooks/QOQ_Sucks.html . What made me look was the the debug 'implicit variable access' list in 5.4.4.38 includes any closure args that don't have the 'arguments' scope added. Fine. Well then in that 2nd link, Zach added a great runnable gist that showed how much fast it is with scoped vars.... only now when I run that gist, it shows there is no difference. So is it not important anymore? Definitely, makes the closures a bit bulkier than they need to be, if it doesn't help anymore.
g
The timing seems quite close - so perhaps it is not an issue any longer? Though in my testing (about 20 times) I saw the scoped version actually SLOWER than the unscoped version, on a few occassions. (It was mostly identical)
d
I’m taking this statement to say it was improved at some point so now it is negligible…maybe?
a
Definitely some huge QoQ improvements, which may mean that query.filter is a lot less compelling, but even back when Zach first did this (image below was what he showed), QoQ was decent in 5.3.2.77. Either way, I wasn't really considering QoQ (rightly or wrongly), but simply looking at writing query.filter according to best practices. And you can see from the image below - at that time unscoped query.filter was > 10x slower than scoped.
👍🏼 1