Hello,
Finally, I've got myself to clean up the 'using' statements sections of my *.mc files because I felt I was using some of these using clauses excessively.
I ended up with the following unanswered questions.
Q1: Why do I have to (as an example) write 'using Toybox.System;', at the beginning of my *.mc file, in order to use 'System.println()' function, but I do not have to write 'using Toybox.Math;' in order to use Math.round() function?
Q2: Could it be that Math module is implicitly made available by including some other module, which is itself including Math module inside?
My data field application is running in the simulator right now, as I am writing this post, which is using a ton of Math functions, without single usage of 'using Toybox.Math;'.
Other modules I am using (and I really must have included them explicitly to avoid compile time or run time error of missing symbol) are:
- Toybox.System
- Toybox.Time
- Toybox.Graphics
- Toybox.Application
- Toybox.WatchUI
Q3: Another question: Do I have to include module in every *.mc file, where I intend to us it's assets, or is it enough to include the module once per application? If latter applies, does it matter in which file (entry point file, any file)?
I ended up randomly adding and removing 'using' statements from all my *.mc files to find minimal working configuration and I hate this lack of understanding and apparent lack of consistency.
Q4: Why are some cases of missing 'using' statement revealed at compile time (as compile time warning), but some only at run time (as exceptions)?
Can somebody give deeper and more comprehensive explanation of using 'using' keyword than found here in section 'Using Statements'?
https://developer.garmin.com/connect-iq/programmers-guide/monkey-c/
Thanks.