MonkeyC module nesting and extending Toybox

Former Member
Former Member

Is it possible to extend the standard Modules with additional functions and classes e.g. Toybox.System - possibly comparable to C# static extension methods?

In which way can I nest modules and what are the limitations? I can't find anything about module Nesting in MonkeyC

I had some trouble using this syntax in two different Source Code files with the same module names - that is why I'm asking the question:

module Generic {

  module Specific {

  }

}

  • Is it possible to extend the standard Modules with additional functions and classes e.g. Toybox.System - possibly comparable to C# static extension methods?

    No. Do not try to extend/modify the built-in modules.

    In which way can I nest modules and what are the limitations? I can't find anything about module Nesting in MonkeyC

    Nested modules are supported and are known to work. The Toybox module is a module, and System is a module nested within it. The Toybox.Application.Properties and Toybox.Application.Settings modules are examples of modules nested three levels deep.

    If you want to nest modules, it is done just like you are showing above.

    I'm not sure what you're trying to get do, but maybe there is a better way. It looks like maybe you are trying to do something like boost::detail to hide implementation details from the public interface of your modules?

  • Former Member
    0 Former Member over 5 years ago in reply to Travis.ConnectIQ

    Ty - so I suppose it is no problem splitting nested modules into multiple source code files?