|
On 22/05/2019 19:52, Roberto Ierusalimschy wrote:
Anyway it boils down to: /is select function still a B-class citizen in PiL4?/PiL4 has an explanation about select somewhat similar to the one in PiL2. However, it makes it clear that loops over varargs with select has a cost that is quadratic with the number of arguments. -- Roberto
Thank you for the answer, Roberto!This explains much. I didn't know it was /so/ costly (now I see why it deserves the ugly functional syntax: it's a sort of warning sign). So it turns out that for performing such a loop it's better to store the varargs in a table {...} beforehand if performance is critical, isn't it?
On a related note, do you plan to improve the situation in Lua 5.4? That is, changing the mechanism underlying varargs to improve performance?
The syntax turns out to be kinda weird, too. Maybe a change of syntax with a new operator instead of a function call, with direct VM support could improve the situation.
IIRC, please correct me if I'm wrong, you are not too fond of varargs, but I find them very useful and expressive in some cases (of course, like any powerful mechanism, you can easily shoot yourself in the foot, if you are not careful), I'd be glad to see some improvement.
Cheers! -- Lorenzo