Wye Semantic Precision is Important in SoftanzaLib?

30 views
Skip to first unread message

Mansour Ayouni

unread,
Oct 10, 2022, 8:16:47 AM10/10/22
to The Ring Programming Language
Hello All,

Sorry for being a bit verbose, However, I hope those who plan to use SoftanzaLib in the future will find this post insightful!

 Let's go...

Because Softanza is designed to support natural language applications,

it offers a high level of semantic precision, and a close adaptation to

the programmer's intent (what I would call Programmer Experience, or PX).


To show this in practice, let's take the example of the Insert() function,

in stzString, stzList, or stzListOfStrings (works the same everywhere!)...


The required job is simple:

- you have an alphabetically-ordered string containing "ACD"

- as you can see, there is a "B" lacking after the "A"

- we wanna use Insert() function to add it

- so the output must be "ABCD"

You would think it's obvious, but wait, there are two different mental paths for solving it, and Softanza wants to enable them both!


Hence, when you process the solution in your mind, and find that your focus should be put first on the substring "B" to be inserted, and after that comes the position where "B" is inserted, then you can translate it directly, in Ring code, in the same order as your train-of-thoughts, like this :


o1 = new stzString("ACD")
o1.Insert( :SubString = "B", :AtPosition = 2 )
? o1.Content() #--> "ABCD"


Otherwise, if the position comes first to your mind, and then comes the letter "B", then you can say:

o1 = new stzString("ACD")
o1.InsertAt( :Position = 2, :SubString = "B")  #--> "ABCD"
? o1.Content()


Well... It seems to be an over-designed feature, since, at a lower level, the same classic insert(n, item) function can do the job and forms what is effectively executed by Ring...

Which is true, but only from a low level, computer-oriented view! In fact, as demonstrated by the examples above, it makes a significant difference from a higher-level, natural-language perspective, to focus on one parameter or another.

At a practical level, whatever code the programmer is writing, it offers the advantage of going inline with his train-of-thought, whatever mental process he opted for to solve the problem.


Softanza will always try its best to not leave you alone when forgetting the syntax of a function and being obliged to go back to documentation. Softanza dislikes mental disruption!


Of course, like any other function in SoftanzaLib, there are short forms that save your time. So the first flavor can be abbreviated to:

o1.Insert("B", 2)

And the second one to:

o1.InsertAt(2, "B")

Here is a snapshot of the sample running in Ring NodePad now:

image.png

And you will get in my next update of the package,soon.


Happ day to all.

Best,

Mansour


Mahmoud Fayed

unread,
Oct 11, 2022, 8:53:19 AM10/11/22
to The Ring Programming Language
Hello Mansour

Thanks for sharing the progress


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