What am I missing about modules?

My initial report follows. But more immediately, I tried opening the mousetrap and distribution center models that use imported modules, and both crashed on my Apple Silicon macos, so maybe the problem I am seeing is more fundamental than me missing something.

Anyway, here’s the question I came with:

Keen to try out the new modules in 7.1.0. I made this model:

Which imports this module called list-utils.nlm

It fails with Nothing named UTILS:JOIN-LIST has been defined.

Incidentally it took quite a few tries to figure out how to use export names which isn’t really adequately documented in the admittedly alpha release. It would also be helpful to note the need to use export in module files in the documentation for import because I was getting beachball of death crashes before I realised that, and while export references import the reverse is not true.

I also tried a procedure (not a reporter) in the module – although I am unsure how this would even work without being able to reference things in the main code – and that failed too.

I also tried without aliasing the module and that failed too.

What am I doing wrong?

Procedure/reporter names inside the export list should not be quoted, so your example should work if you change the module code to:

@David_OSullivan I just tried the models you mentioned on my Apple Silicon laptop, and they worked as expected, as far as I can tell. Could you be more specific about what happened when you tried to run them, or provide any error messages that appear, either from NetLogo or the OS?

Thank you for this. I was sure I had tried that, but I think what I tried was

export (list join-list)

and that hung – as I’ve just reconfirmed it still does.

In short, the documentation of export really needs some care and attention, as it’s not even clear in its current state that you have to supply a bracketed list, and that it’s not actually a ‘list’ as such, it’s more like a globals or turtles-own statement syntactically.

Anyway, I think the issue with Mousetrap and Distribution Center models was clearly related to crash conditions on my simple test example. Once I got that working, the models in the library worked fine! There must have been something hanging around in the system state after it crashed on my test model that caused the library models to fail also.

However… one thing that seems common both to my test model, and to the library models, is when I try to open the imported .nlm file which is offered as an option in the Included Files drop-down list, I get an Internal Error (details pasted below). If such files aren’t viewable from the model (which would make sense so they don’t get edited willy-nilly) then they shouldn’t appear in the drop-down.

These teething problems aside, I am looking forward to making use of this huge enhancement to the language!

Here’s that error report (on macOS Tahoe 26.5.2)

Thanks for sharing the error, we’ll take note of that for the next release. That’s definitely just a bug; you are supposed to be able to open and edit .nlm files in the app. Thank you for testing, and I’m glad to hear that you’re excited to try out the new functionality!

I got the same error message on a Windows machine, after a fresh start of NetLogo (7.1.0-alpha1) – exact same stack trace.

After opening the other example model, clicking the .nlm file from the dropdown list did nothing, but “Open Source File…” and then navigating to time-series.nl does work.

Then going back to the other example model, no crash, no other effect, and again opening explicitly does work.

(This seems not completely reproducible. Second time I get repeated error messages…)

About the documentation:
The description of import is adequate. An additional example linking a definition to its use (something like utils:add with parameters) might be useful.
However, the description of export is not enough to get started. For more information, it refers back to import.

Links in the announcement and release notes for more information about the import mechanism refer to the dictionary entry for import. I had hoped for a more extensive description of the mechanism, from export perspective as well as import perspective.

David and Mark,

The included files dropdown bug is now fixed. We will definitely work on improving the documentation of the module system for the next release of 7.1, but for now, feel free to ask any specific questions here on the Forum.

1 Like