Hello Mansour
Thanks for sharing
Also, I will share some of the related information :D
(1) RingQt was one of the early extensions that I started developing for Ring, even before have the Ring code generator for extensions. After adding support for few controls like QWidget, QLabel, QPushButton, etc. I started to feel that I am repeating myself and I would need many years of work to cover the classes that I need from RingQt. And when I developed the (Code generator for extension), it was designed to support C (not C++) and as you know RingQt is based on C++, so it was very fun to extend the code generator with more features that enable us to support C++ classes, by generating C functions (wrappers around these classes) at first then generating Ring code (Classes around C functions). Later our friend Majdi Sobain developed a GUI tools (Qt Class Converter) that helps in generating configuration files for the code generator. This was a success story, (The ability to support C++ libraries) and later we supported cpphttplib which uses C++ classes too.
(2) Using globals(), len() and the load command, we can get information about the list of constants defined by each library from Ring code.
? len(globals())
load "libuv.ring"
? len(globals())
load "guilib.ring"
? len(globals())
? globals()
Output:
0
205
594
Note: we can print the output of globals() function (Just a Ring list contains many strings where each string is the variable/constant name)
(3) Using the Global Scope is good for flexibility but it's dangerous, it could lead to name conflicts between (Global name & Class Attribute/Local Variable, etc.). In Ring design, we choose flexibility first and we Favor syntax that uses short code, this lead to good solutions to problems (which requires time), so we introduced the (load package) command which load source code files in separate global scope
So, using
load package "mylib.ring"
This means that, I want to access the functions/classes/packages in this mylib.ring file, but I don't want to see the global variables defined by this file, but the functions/classes that does exist inside mylib.ring can see their global scope.
When thinking about using (load package) or just using (load) this means the caller have the control about sharing the global scope
But this feature could be used inside the (library/framework) that we design and avoid sharing the global scope for your functions/classes, while sharing a file for constants
Example:
stzlib_constants.ring ---> Here you could have a file for the library constants.
stzlib_loader.ring ---> Here you could have a file that load the library files using load command
stzlib.ring ----> Here you can use load package "stzlib_loader.ring" before/after load "stzlib_constants.ring"
Now in the application code (that uses stzlib.ring)
Even if I used: load "stzlib.ring"
The library will use its custom global scope for its classes ---> conflicts because of global (outside stzlib.ring) will never happens
Greetings,
Mahmoud