SlideShare a Scribd company logo
Ring Documentation, Release 1.7
hello=0 it=0 is=0 me=0
func GetHello
See "Hello" + nl
func braceEnd
See "Goodbye!" + nl
We can execute code written in strings using the Eval() function
cCode = "See 'Code that will be executed later!' "
Eval(cCode) # execute the code to print the message
We can create a list then execute code generated from that list
aWords = ["hello","it","is","me"]
for word in aWords cCode=word+"=0" eval(cCode) next
We can read text files using the Read(cFileName) function and we can write files using the Write(cFileName,cString)
function.
See "Enter File Name:" Give cFileName See Read(cFileName) # Print the file content
The next example presents how to create a class that defines two instructions The first instruction is : I want window
The second instruction is : Window title = Expression Also keywords that can be ignored like the ‘the’ keyword
New App
{
I want window
The window title = "hello world"
}
Class App
# Attributes for the instruction I want window
i want window
nIwantwindow = 0
# Attributes for the instruction Window title
# Here we don't define the window attribute again
title
nWindowTitle = 0
# Keywords to ignore, just give them any value
the=0
func geti
if nIwantwindow = 0
nIwantwindow++
ok
func getwant
if nIwantwindow = 1
nIwantwindow++
ok
func getwindow
if nIwantwindow = 2
nIwantwindow= 0
see "Instruction : I want window" + nl
ok
if nWindowTitle = 0
nWindowTitle++
3.7. Define Natural Statements 32
Ring Documentation, Release 1.7
ok
func settitle cValue
if nWindowTitle = 1
nWindowTitle=0
see "Instruction : Window Title = " + cValue + nl
ok
To complete the previous example, use read() to get the content of a file that contains
I want window
The window title = "hello world"
Then use eval() to execute the content of that file!. Also, you can update the methods GetWindow() and SetTitle() to
create Real windows using the GUI Library
3.8 Define Declarative Languages
We learned how to use Natural statements to execute our code and using the same features we can use nested structures
to execute our code.
The next example from the Web library, generate HTML document using the Bootstrap library. No HTML code is
written directly in this example, we created a similar language (just as example) Then using this declarative language
that uses nested structures, we generated the HTML Document.. The idea in this example is that the GetDiv() and
GetH1() methods return an object that we can access using {} and after each object access the method BraceEnd() will
be executed to send the generated HTML to the parent object until we reach to the root where BraceEnd() will print
the output.
Load "weblib.ring"
Import System.Web
Func Main
BootStrapWebPage()
{
div
{
classname = :container
div
{
classname = :jumbotron
H1 { text("Bootstrap Page") }
}
div
{
classname = :row
for x = 1 to 3
div
{
classname = "col-sm-4"
H3 { html("Welcome to the Ring programming language") }
P { html("Using a scripting language is very fun!") }
}
next
}
}
}
3.8. Define Declarative Languages 33
Ring Documentation, Release 1.7
The classes that power the declarative interface looks like this
Class Link from ObjsBase
title link
Func braceend
cOutput = nl+GetTabs() + "<a href='" +
Link + "'> "+ Title + " </a> " + nl
Class Div from ObjsBase
Func braceend
cOutput += nl+'<div'
addattributes()
AddStyle()
getobjsdata()
cOutput += nl+"</div>" + nl
cOutput = TabMLString(cOutput)
3.9 Syntax Flexibility
Ring comes with many styles for writing your source code!
Also you can change the language keywords and operators and create your custom style!
3.10 Transparent Implementation
Ring comes with transparent implementation. We can know what is happening in each compiler stage and what is
going on during the run-time by the Virtual Machine Example : ring helloworld.ring -tokens -rules -ic
See "Hello, World!"
Output
==================================================================
Tokens - Generated by the Scanner
==================================================================
Keyword : SEE
Literal : Hello, World!
EndLine
==================================================================
==================================================================
Grammar Rules Used by The Parser
==================================================================
Rule : Program --> {Statement}
Line 1
Rule : Factor --> Literal
Rule : Range --> Factor
Rule : Term --> Range
Rule : Arithmetic --> Term
Rule : BitShift --> Arithmetic
Rule : BitAnd --> BitShift
3.9. Syntax Flexibility 34
Ring Documentation, Release 1.7
Rule : BitOrXOR --> BitAnd
Rule : Compare --> BitOrXOR
Rule : EqualOrNot --> Compare
Rule : LogicNot -> EqualOrNot
Rule : Expr --> LogicNot
Rule : Statement --> 'See' Expr
==================================================================
==================================================================
Byte Code - Before Execution by the VM
==================================================================
PC OPCode Data
1 FuncExE
2 PushC Hello, World!
3 Print
4 ReturnNull
==================================================================
Hello, World!
3.11 Visual Implementation
The Ring programming language is designed using the PWCT visual programming tool and you will find the visual
source of the language in the folder “visualsrc” - *.ssf files and the generated source code (In the C Language) in the
src folder and the include folder.
The next screen shot from the ring_vm.ssf file (Generate ring_vm.c and ring_vm.h)
3.11. Visual Implementation 35
Ring Documentation, Release 1.7
The next screen shot from the ring_list.ssf file (Generate ring_list.c and ring_list.h)
3.12 Smart Garbage Collector
Avoid memory problems :-
• Invalid Memory Access
• Memory leaks
• Uninitialized Memory Access
• Dangling pointer
Rules :-
• Global variables always stay in the memory, until you delete these variables using the assignment statement.
• Local variables always deleted after the end of the function.
• The programmer have full control on when to delete the variable from the memory using the Assignment state-
ment.
Example:
aList = [1,2,3,4,5]
aList = "nice"
After the second line directly, The list [1,2,3,4,5] will be deleted from the memory and we will have a string “nice”
• The programmer can call the function callgc() to force running the garbage collector.
• If we have a reference to a variable (when we pass objects and lists to functions), then deleting variables will be
based on reference counting, if no references everything will be deleted, but if we have a reference, the data will
stay in memory.
3.12. Smart Garbage Collector 36
Ring Documentation, Release 1.7
3.13 No Global Interpreter (VM) Lock - No GIL
When we use threads in Ring applications, We don’t have global interpreter (VM) lock (No GIL)
So threads can work in parallel and execute Ring instructions at the same time
This is better for threads and concurrency (More Faster!)
3.13. No Global Interpreter (VM) Lock - No GIL 37
CHAPTER
FOUR
WHAT IS NEW IN RING 1.7?
In this chapter we will learn about the changes and new features in Ring 1.7 release.
4.1 List of changes and new features
Ring 1.7 comes with many new features!
• New Command: Load Package
• ringvm_see() and ringvm_give() functions
• ring_state_new() and ring_state_mainfile() functions
• Better Trace Library
• Better Ring Notepad
• Better RingQt
• Better Ring2EXE
• Better RingZip
• Better Documentation
• Better Ring VM
• RingLibuv Extension
4.2 New Command: Load Package
Using the ‘load’ command we can use many ring source files in the same project
But all of these files will share the same global scope
Now we have the “Load Package” command too
Using “Load Package” we can load a library (*.ring file) in new global scope
This is very useful to create libraries that avoid conflicts in global variables
Example:
File: loadpackage.ring
38
Ring Documentation, Release 1.7
x = 100
? "Hello, World!"
load package "testloadpackage.ring"
? x
test()
File: testloadpackage.ring
? "Hello from testloadpackage.ring"
x = 1000
test()
func test
? x
Output:
Hello, World!
Hello from testloadpackage.ring
1000
100
1000
4.3 ringvm_see() and ringvm_give() functions
Using the ringvm_see() function we can redefine the behavior of the See command
Also we can use ring_see() to have the original behavior
Example:
see "Hello world" + nl
see 123 + nl
see ["one","two","three"]
see new point {x=10 y=20 z=30}
func ringvm_see t
ring_see("We want to print: ")
ring_See(t)
class point x y z
Output:
We want to print: Hello world
We want to print: 123
We want to print: one
two
three
We want to print: x: 10.000000
y: 20.000000
z: 30.000000
Using the ringvm_give() function we can redefine the behavior of the Give command
Also we can use ring_give() to have the original behavior
4.3. ringvm_see() and ringvm_give() functions 39
Ring Documentation, Release 1.7
Example:
see "Name: " give name
see "Hello " + name
func ringvm_give
see "Mahmoud" + nl
return "Mahmoud"
Output:
Name: Mahmoud
Hello Mahmoud
4.4 ring_state_new() and ring_state_mainfile() functions
Using ring_state_new() and ring_state_mainfile() we can run Ring programs from Ring programs
But unlike ring_state_main(), Here we can control when to delete the Ring state!
This is important when we run GUI programs from GUI programs
Because they will share the GUI Library (RingQt), And In this case the caller will call
qApp.Exec()
So the sub program, will not stop and will return to the Main program
Here deleting the State of the sub programs will lead to a problem when we run the sub program events
So keeping the state is important for sub GUI programs hosted in GUI programs.
4.5 Better Trace Library
The Trace library is updated, In the Debugger at break points we have now the “callstack” command
This command will print the functions call stack.
Example:
load "tracelib.ring"
func main
? "Hello from main!"
test1()
func test1
? "Hello from test1!"
test2()
func test2
? "Hello from test2!"
test3()
func test3
? "Hello from test3!"
breakpoint()
4.4. ring_state_new() and ring_state_mainfile() functions 40
Ring Documentation, Release 1.7
4.6 Better Ring Notepad
Ring Notepad comes with the next updates
1. Support *.cf extension
2. Using Hash function (SHA256) for better “Save Changes?” message
3. Ring Notepad - X Button - Ask for saving changes?
4.7 Better RingQt
The next classes are added to RingQt
1. QStackedWidget
2. QCalendarWidget
3. QOpenGLFunctions
4. QOpenGLContext
5. QSurfaceFormat
6. QOpenGLWidget
7. QOpenGLVersionProfile
8. QOpenGLFunctions_3_2_Core
9. QVector2D
10. QVector3D
11. QVector4D
4.6. Better Ring Notepad 41

More Related Content

What's hot (20)

PDF
The Ring programming language version 1.10 book - Part 31 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 48 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 13 of 181
Mahmoud Samir Fayed
 
PPTX
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
 
PPTX
Php sql-android
maamir farooq
 
PDF
The Ring programming language version 1.7 book - Part 29 of 196
Mahmoud Samir Fayed
 
PPTX
#5 (Remote Method Invocation)
Ghadeer AlHasan
 
PDF
The Ring programming language version 1.5.4 book - Part 26 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 33 of 210
Mahmoud Samir Fayed
 
PDF
MultiClient chatting berbasis gambar
yoyomay93
 
PPTX
ES6 in Real Life
Domenic Denicola
 
PDF
The Ring programming language version 1.10 book - Part 19 of 212
Mahmoud Samir Fayed
 
PDF
JJUG CCC 2011 Spring
Kiyotaka Oku
 
PDF
Laporan multiclient chatting berbasis grafis (gambar)
Rara Ariesta
 
PDF
The Ring programming language version 1.6 book - Part 28 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 13 of 189
Mahmoud Samir Fayed
 
PDF
Spock: A Highly Logical Way To Test
Howard Lewis Ship
 
PDF
The Ring programming language version 1.6 book - Part 41 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 27 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 19 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 31 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 48 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 13 of 181
Mahmoud Samir Fayed
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
 
Php sql-android
maamir farooq
 
The Ring programming language version 1.7 book - Part 29 of 196
Mahmoud Samir Fayed
 
#5 (Remote Method Invocation)
Ghadeer AlHasan
 
The Ring programming language version 1.5.4 book - Part 26 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 33 of 210
Mahmoud Samir Fayed
 
MultiClient chatting berbasis gambar
yoyomay93
 
ES6 in Real Life
Domenic Denicola
 
The Ring programming language version 1.10 book - Part 19 of 212
Mahmoud Samir Fayed
 
JJUG CCC 2011 Spring
Kiyotaka Oku
 
Laporan multiclient chatting berbasis grafis (gambar)
Rara Ariesta
 
The Ring programming language version 1.6 book - Part 28 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 13 of 189
Mahmoud Samir Fayed
 
Spock: A Highly Logical Way To Test
Howard Lewis Ship
 
The Ring programming language version 1.6 book - Part 41 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 27 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 19 of 202
Mahmoud Samir Fayed
 

Similar to The Ring programming language version 1.7 book - Part 7 of 196 (20)

PDF
The Ring programming language version 1.8 book - Part 7 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 6 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 7 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 7 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 7 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 5 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.4 book - Part 6 of 185
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 6 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 7 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.1 book - Part 13 of 180
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.6 book - Part 16 of 189
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 5 of 88
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 17 of 196
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 88 of 202
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.9 book - Part 11 of 210
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.2 book - Part 4 of 84
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 14 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.3 book - Part 85 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.5.2 book - Part 14 of 181
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.8 book - Part 9 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 7 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 6 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 7 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 7 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 7 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 5 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 6 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 6 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 7 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 13 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 16 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 5 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 17 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 88 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 11 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 4 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 14 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 85 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 14 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 9 of 202
Mahmoud Samir Fayed
 
Ad

More from Mahmoud Samir Fayed (20)

PDF
The Ring programming language version 1.10 book - Part 212 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 211 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 210 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 208 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 207 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 205 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 206 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 204 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 203 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 202 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 201 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 200 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 199 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 198 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 197 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 196 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 195 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 194 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 193 of 212
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.10 book - Part 192 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 212 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 211 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 210 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 208 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 207 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 205 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 206 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 204 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 203 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 202 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 201 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 200 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 199 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 198 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 197 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 196 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 195 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 194 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 193 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 192 of 212
Mahmoud Samir Fayed
 
Ad

Recently uploaded (20)

DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Biography of Daniel Podor.pdf
Daniel Podor
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
July Patch Tuesday
Ivanti
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 

The Ring programming language version 1.7 book - Part 7 of 196

  • 1. Ring Documentation, Release 1.7 hello=0 it=0 is=0 me=0 func GetHello See "Hello" + nl func braceEnd See "Goodbye!" + nl We can execute code written in strings using the Eval() function cCode = "See 'Code that will be executed later!' " Eval(cCode) # execute the code to print the message We can create a list then execute code generated from that list aWords = ["hello","it","is","me"] for word in aWords cCode=word+"=0" eval(cCode) next We can read text files using the Read(cFileName) function and we can write files using the Write(cFileName,cString) function. See "Enter File Name:" Give cFileName See Read(cFileName) # Print the file content The next example presents how to create a class that defines two instructions The first instruction is : I want window The second instruction is : Window title = Expression Also keywords that can be ignored like the ‘the’ keyword New App { I want window The window title = "hello world" } Class App # Attributes for the instruction I want window i want window nIwantwindow = 0 # Attributes for the instruction Window title # Here we don't define the window attribute again title nWindowTitle = 0 # Keywords to ignore, just give them any value the=0 func geti if nIwantwindow = 0 nIwantwindow++ ok func getwant if nIwantwindow = 1 nIwantwindow++ ok func getwindow if nIwantwindow = 2 nIwantwindow= 0 see "Instruction : I want window" + nl ok if nWindowTitle = 0 nWindowTitle++ 3.7. Define Natural Statements 32
  • 2. Ring Documentation, Release 1.7 ok func settitle cValue if nWindowTitle = 1 nWindowTitle=0 see "Instruction : Window Title = " + cValue + nl ok To complete the previous example, use read() to get the content of a file that contains I want window The window title = "hello world" Then use eval() to execute the content of that file!. Also, you can update the methods GetWindow() and SetTitle() to create Real windows using the GUI Library 3.8 Define Declarative Languages We learned how to use Natural statements to execute our code and using the same features we can use nested structures to execute our code. The next example from the Web library, generate HTML document using the Bootstrap library. No HTML code is written directly in this example, we created a similar language (just as example) Then using this declarative language that uses nested structures, we generated the HTML Document.. The idea in this example is that the GetDiv() and GetH1() methods return an object that we can access using {} and after each object access the method BraceEnd() will be executed to send the generated HTML to the parent object until we reach to the root where BraceEnd() will print the output. Load "weblib.ring" Import System.Web Func Main BootStrapWebPage() { div { classname = :container div { classname = :jumbotron H1 { text("Bootstrap Page") } } div { classname = :row for x = 1 to 3 div { classname = "col-sm-4" H3 { html("Welcome to the Ring programming language") } P { html("Using a scripting language is very fun!") } } next } } } 3.8. Define Declarative Languages 33
  • 3. Ring Documentation, Release 1.7 The classes that power the declarative interface looks like this Class Link from ObjsBase title link Func braceend cOutput = nl+GetTabs() + "<a href='" + Link + "'> "+ Title + " </a> " + nl Class Div from ObjsBase Func braceend cOutput += nl+'<div' addattributes() AddStyle() getobjsdata() cOutput += nl+"</div>" + nl cOutput = TabMLString(cOutput) 3.9 Syntax Flexibility Ring comes with many styles for writing your source code! Also you can change the language keywords and operators and create your custom style! 3.10 Transparent Implementation Ring comes with transparent implementation. We can know what is happening in each compiler stage and what is going on during the run-time by the Virtual Machine Example : ring helloworld.ring -tokens -rules -ic See "Hello, World!" Output ================================================================== Tokens - Generated by the Scanner ================================================================== Keyword : SEE Literal : Hello, World! EndLine ================================================================== ================================================================== Grammar Rules Used by The Parser ================================================================== Rule : Program --> {Statement} Line 1 Rule : Factor --> Literal Rule : Range --> Factor Rule : Term --> Range Rule : Arithmetic --> Term Rule : BitShift --> Arithmetic Rule : BitAnd --> BitShift 3.9. Syntax Flexibility 34
  • 4. Ring Documentation, Release 1.7 Rule : BitOrXOR --> BitAnd Rule : Compare --> BitOrXOR Rule : EqualOrNot --> Compare Rule : LogicNot -> EqualOrNot Rule : Expr --> LogicNot Rule : Statement --> 'See' Expr ================================================================== ================================================================== Byte Code - Before Execution by the VM ================================================================== PC OPCode Data 1 FuncExE 2 PushC Hello, World! 3 Print 4 ReturnNull ================================================================== Hello, World! 3.11 Visual Implementation The Ring programming language is designed using the PWCT visual programming tool and you will find the visual source of the language in the folder “visualsrc” - *.ssf files and the generated source code (In the C Language) in the src folder and the include folder. The next screen shot from the ring_vm.ssf file (Generate ring_vm.c and ring_vm.h) 3.11. Visual Implementation 35
  • 5. Ring Documentation, Release 1.7 The next screen shot from the ring_list.ssf file (Generate ring_list.c and ring_list.h) 3.12 Smart Garbage Collector Avoid memory problems :- • Invalid Memory Access • Memory leaks • Uninitialized Memory Access • Dangling pointer Rules :- • Global variables always stay in the memory, until you delete these variables using the assignment statement. • Local variables always deleted after the end of the function. • The programmer have full control on when to delete the variable from the memory using the Assignment state- ment. Example: aList = [1,2,3,4,5] aList = "nice" After the second line directly, The list [1,2,3,4,5] will be deleted from the memory and we will have a string “nice” • The programmer can call the function callgc() to force running the garbage collector. • If we have a reference to a variable (when we pass objects and lists to functions), then deleting variables will be based on reference counting, if no references everything will be deleted, but if we have a reference, the data will stay in memory. 3.12. Smart Garbage Collector 36
  • 6. Ring Documentation, Release 1.7 3.13 No Global Interpreter (VM) Lock - No GIL When we use threads in Ring applications, We don’t have global interpreter (VM) lock (No GIL) So threads can work in parallel and execute Ring instructions at the same time This is better for threads and concurrency (More Faster!) 3.13. No Global Interpreter (VM) Lock - No GIL 37
  • 7. CHAPTER FOUR WHAT IS NEW IN RING 1.7? In this chapter we will learn about the changes and new features in Ring 1.7 release. 4.1 List of changes and new features Ring 1.7 comes with many new features! • New Command: Load Package • ringvm_see() and ringvm_give() functions • ring_state_new() and ring_state_mainfile() functions • Better Trace Library • Better Ring Notepad • Better RingQt • Better Ring2EXE • Better RingZip • Better Documentation • Better Ring VM • RingLibuv Extension 4.2 New Command: Load Package Using the ‘load’ command we can use many ring source files in the same project But all of these files will share the same global scope Now we have the “Load Package” command too Using “Load Package” we can load a library (*.ring file) in new global scope This is very useful to create libraries that avoid conflicts in global variables Example: File: loadpackage.ring 38
  • 8. Ring Documentation, Release 1.7 x = 100 ? "Hello, World!" load package "testloadpackage.ring" ? x test() File: testloadpackage.ring ? "Hello from testloadpackage.ring" x = 1000 test() func test ? x Output: Hello, World! Hello from testloadpackage.ring 1000 100 1000 4.3 ringvm_see() and ringvm_give() functions Using the ringvm_see() function we can redefine the behavior of the See command Also we can use ring_see() to have the original behavior Example: see "Hello world" + nl see 123 + nl see ["one","two","three"] see new point {x=10 y=20 z=30} func ringvm_see t ring_see("We want to print: ") ring_See(t) class point x y z Output: We want to print: Hello world We want to print: 123 We want to print: one two three We want to print: x: 10.000000 y: 20.000000 z: 30.000000 Using the ringvm_give() function we can redefine the behavior of the Give command Also we can use ring_give() to have the original behavior 4.3. ringvm_see() and ringvm_give() functions 39
  • 9. Ring Documentation, Release 1.7 Example: see "Name: " give name see "Hello " + name func ringvm_give see "Mahmoud" + nl return "Mahmoud" Output: Name: Mahmoud Hello Mahmoud 4.4 ring_state_new() and ring_state_mainfile() functions Using ring_state_new() and ring_state_mainfile() we can run Ring programs from Ring programs But unlike ring_state_main(), Here we can control when to delete the Ring state! This is important when we run GUI programs from GUI programs Because they will share the GUI Library (RingQt), And In this case the caller will call qApp.Exec() So the sub program, will not stop and will return to the Main program Here deleting the State of the sub programs will lead to a problem when we run the sub program events So keeping the state is important for sub GUI programs hosted in GUI programs. 4.5 Better Trace Library The Trace library is updated, In the Debugger at break points we have now the “callstack” command This command will print the functions call stack. Example: load "tracelib.ring" func main ? "Hello from main!" test1() func test1 ? "Hello from test1!" test2() func test2 ? "Hello from test2!" test3() func test3 ? "Hello from test3!" breakpoint() 4.4. ring_state_new() and ring_state_mainfile() functions 40
  • 10. Ring Documentation, Release 1.7 4.6 Better Ring Notepad Ring Notepad comes with the next updates 1. Support *.cf extension 2. Using Hash function (SHA256) for better “Save Changes?” message 3. Ring Notepad - X Button - Ask for saving changes? 4.7 Better RingQt The next classes are added to RingQt 1. QStackedWidget 2. QCalendarWidget 3. QOpenGLFunctions 4. QOpenGLContext 5. QSurfaceFormat 6. QOpenGLWidget 7. QOpenGLVersionProfile 8. QOpenGLFunctions_3_2_Core 9. QVector2D 10. QVector3D 11. QVector4D 4.6. Better Ring Notepad 41