remove arg.n

Feature requests for future versions of Hollywood can be voiced here
Post Reply
Bugala
Posts: 689
Joined: Sun Feb 14, 2010 8:11 pm

remove arg.n

Post by Bugala » Sat Jun 17, 2017 11:03 pm

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.

User avatar
airsoftsoftwair
Posts: 2537
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: remove arg.n

Post by airsoftsoftwair » Sun Jun 18, 2017 7:55 pm

Well, of course TableItems() needs some time to compute the number of items in the table. Using arg.n is much faster :)

Post Reply