Sign in to follow this  
Followers 0
luzif3r

globals in udfs

3 posts in this topic

i finished writing a huge function and after careful review figured i break it down into several key functions to save space , readability, etc.

now i read that it is advised to use locals but i would have to pass over unseemingly many parameters to my functions, which instead could just be global vars. saw it in several other udfs too, but im unsure what is better :D

gist of my rambling: many globals ok/big nono/some ok ?

Share this post


Link to post
Share on other sites



When I write functions I like to see them as independent pieces of code that works regardless of how a function before behaved, and I also like to be able to change one function without having to consider the other functions in my script. This is somewhat broken if you decide to go with many globals since other functions may interfer with data that other functions is supposed to get. This could make debugging hard. But on the other hand, passing around data that most likely never changes is just plain stupid. I guess a mixture is the best. :D


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Thanks for the reply monoceres. My subfunctions will only be called by my bigger function which is the only one that should ever be called from outside anyways. So i will go for some globals.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0