Page 1 of 1

remove arg.n

Posted: Sat Jun 17, 2017 11:03 pm
by Bugala
This time not a feature request, but a request to remove a feature.

When using

Code: Select all

function func(...)
it always sends a table that contains the sent args, plus the n counter.

However, as i was thinking about it, this n actually creates more problems than it solves.

Unless I am missing something here, there is no need for n as it can simply be done with

Code: Select all

TableItems(arg)
Instead, it more often makes code more complicated.

For example as i was about to use

Code: Select all

foreach(arg, mysubfunction(key, value))
it didnt work, since mysubfunction was assuming all items were tables, but since n isnt, it failed at that point. So i had to make extra effort and use:

Code: Select all

if gettype(key) = #TABLE
endif
And this makes the code much messier when task was somewhat simple otherwise.
Not to mention if I was sending a table of numbers that i want to go through each, favorably with "foreach" then to find out to skip n, i would need to compare the key if it is "n" or not. It also makes me worry if you are planning to add even more features to this spot, in which case code i make now, might be necessary to redo in future since they might not be able to handle the new arg.x.

Hence I am suggesting of removing arg.n from future hollywood versions unless it has some purpose that I am missing about it.

Re: remove arg.n

Posted: Sun Jun 18, 2017 7:55 pm
by airsoftsoftwair
Well, of course TableItems() needs some time to compute the number of items in the table. Using arg.n is much faster :)