I am developing a simulation in NetLogo that will ultimately have multiple permutations. In the end, I’ll have Sim1.nlogo, Sim2.nlogo, Sim3.nlogo, et cetera all including libsim.nls.
What I’d like to know is, if I have a function in libsim.nls that is identical in all but one of my models, can I overload it in the model that differs, or will I have to duplicate the code manually in each permutation?
The exact thing you’re asking for isn’t possible. But you don’t need to duplicate code in all of the models, either.
I’d suggest the following approach. In
libsim.nls, give the standard implementation a standard name likefoo-standard. Then inSim1.nlogoandSim2.nlogoyou can have the one-linerto foo foo-standard end, and in Sim3.nlogo you can haveto foo ... endwith a different body, that doesn’t call the “standard” implementation.