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.

If I have a situation where file A imports files B and C, and files B and C both import file D is that going to cause any sort of conflict when a call is made to a function in file D?

0
Posted

If I have a situation where file A imports files B and C, and files B and C both import file D is that going to cause any sort of conflict when a call is made to a function in file D?

0

No. Question: If file A imports file B and file B imports file C, does file C get re-imported every time the function in file B is called? If so is there any potential conflict there, and how much will this impact overall efficiency? Answer: No, functions in file C do not get re-imported every time the function in file B is called. However, we should point out that file C will, in fact, be re-imported every time. Now, none of the functions in it will get imported, but the file will be retrieved and parsed each time you try to import something from it. Depending on how big this file is, and how often you are calling the function which imports it, you might either set a STAF variable (with the job number somewhere in it) that you can retrieve across function calls, or have the importing function use “global” scope and set a STAX variable that indicates the import has already been done. You can see this for yourself if you’d like by looking at STAXResult after each element.

Related Questions

What is your question?

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

Experts123