Unified Global Constants and Enums

120 views
Skip to first unread message

Mansour Ayouni

unread,
Aug 22, 2025, 7:18:45 PMAug 22
to The Ring Programming Language

Hello Mahmoud,

I was thinking today about the big effort you made in creating the central global constants and enums files for many extensions, especially RingQt.

I had to do something similar for the reactive system I’m working on in StzLib, and it took me a whole week (to extract the constants, understand their practical use cases, carefully name them, and finally use them all over the codebase) .

I had to figure out the functions supported by RingLibUV (which are not documented) and read a lot of documentation and online examples to understand each parameter.

image.png

Honestly, without the help of ClaudeAI, I could not have finished it so quickly. But you did it before the AI era — and that makes your work even more impressive and really worth appreciating!

Link to the file if you want to take a look:

Sincerely,
Mansour

Mahmoud Fayed

unread,
Aug 22, 2025, 7:52:46 PMAug 22
to The Ring Programming Language
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

Mansour Ayouni

unread,
Aug 23, 2025, 8:20:30 AMAug 23
to Mahmoud Fayed, The Ring Programming Language
 Hello Mahmoud,

We always learn with you, very interesting information!

Thank you.
Mansour

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ring-lang/fa1ca10a-6f55-491d-b3a9-f9c52a3363ecn%40googlegroups.com.

Mahmoud Fayed

unread,
Aug 23, 2025, 12:16:50 PMAug 23
to The Ring Programming Language
Hello Mansour

>> "We always learn with you, very interesting information!"

Thanks for your kind words :D

Greetings,
Mahmoud
Reply all
Reply to author
Forward
0 new messages