Max Number of vars passed to a function?

Blitz3D Forums/Blitz3D Programming/Max Number of vars passed to a function?

Stevie G(Posted 2006) [#1]
Anyone ever experienced a limit? I'm looking to pass 20 or more elements.

Cheers
Stevie


Jams(Posted 2006) [#2]
Not sure on the exact figure but you'll have no problems passing 20 parameters, the limit is probably 128 or 255 or something like that.


Stevie G(Posted 2006) [#3]
Good news ... will never need as many as that but just need to be sure and wanted to avoid banks with what I'm doing.

Cheers
Stevie


Ching(Posted 2006) [#4]
I highly advise avoiding banks at all times, every time I use them I become poorer.


Picklesworth(Posted 2006) [#5]
It may be possible, but I don't think you should have a function that takes 20 elements...
6 is about as much as I can stand, personally, and that's only if they are all related. (eg: x,y,z,pi,ya,ro).

Unless there's something weird and wonderful being done here which involves functions with lots of arguments used in a unique way, that is :)


Stevie G(Posted 2006) [#6]
Agree Mr P,

I changed this so that the elements are read from data statements or a file.

Stevie


octothorpe(Posted 2006) [#7]
Use Type objects, not banks, to move around related variables. There's nothing wrong with defining a type merely to simplify the interface between two separate sections of your code. If you have more than 7 parameters, something is wrong with your design.


Stevie G(Posted 2006) [#8]
Use Type objects, not banks, to move around related variables. There's nothing wrong with defining a type merely to simplify the interface between two separate sections of your code. If you have more than 7 parameters, something is wrong with your design.



I already do this and like I said above .. I've already scrapped the ( horrific ) idea of passing alot of stuff to a function. There is nothing wrong with my design.


jfk EO-11110(Posted 2006) [#9]
Types may be handy, but you need to define them first, while a bank can be created and removed dynamicly, so the structure of an interface can be defined dynamicly as well. When you know how to use banks then they may give you max flexibility.

Bysides, I have several functions that are taking a lot of arguments, because they are complex functions, eg:

Function CreateSunbeams(texpath$,transp=40,numsurfx#=5,numsurfy#=5,zoom#=1.0,height#=-1.0,lenght#=3.0,vertical_on=1,horizontal_on=1)

Each one is required. Banks and Types are rather useful when there are multiple return values.


Sir Gak(Posted 2006) [#10]
Ching: can you explain why you don't like Banks?


octothorpe(Posted 2006) [#11]
I can.

They are error prone in that they rely on the programmer to remember which fields go where. Types allow the compiler to type check your values for you. Flexibility is not always worth the cost.


big10p(Posted 2006) [#12]
Actually, I think Ching was just making a joke. banks -> poorer... geddit? :)


jfk EO-11110(Posted 2006) [#13]
The trick is to use banks only when you already know they are not "cleared". ;)