Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Are there any disadvantages to dispensing with global variables?

0
Posted

Are there any disadvantages to dispensing with global variables?

0

If there are, no-one has reported them yet. It’s common in some other programming languages not to use a lot of global variables. It certainly makes things a good deal easier to code and trace. You never have to declare globals at the beginning of a handler and that saves time. Very often you don’t know in advance, which globals are going to be need in a handler but you still have to declare in the handler. For example, consider a switch where each case is going to need a different set of globals. Yes, you can declare globals on the fly as you drop into each case that uses them but it does get confusing and each time you do, SuperCard has to locate the globals all over again. With the YAVglobal, you have all your data in one place, stored as “records” in a large multidimensional array. You can set or get (using “Sett” or “Gett”) any of these global records from anywhere without needind a global declaration: simply use a function statement instead (after which, if you need that data mor

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123