Max Number of vars passed to a function?
Blitz3D Forums/Blitz3D Programming/Max Number of vars passed to a function?
| ||
Anyone ever experienced a limit? I'm looking to pass 20 or more elements. Cheers Stevie |
| ||
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. |
| ||
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 |
| ||
I highly advise avoiding banks at all times, every time I use them I become poorer. |
| ||
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 :) |
| ||
Agree Mr P, I changed this so that the elements are read from data statements or a file. Stevie |
| ||
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. |
| ||
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. |
| ||
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. |
| ||
Ching: can you explain why you don't like Banks? |
| ||
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. |
| ||
Actually, I think Ching was just making a joke. banks -> poorer... geddit? :) |
| ||
The trick is to use banks only when you already know they are not "cleared". ;) |