Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline ioan92  
#1 Posted : 04 November 2024 01:14:05(UTC)
ioan92


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2012(UTC)
Posts: 93
France, Metropolitan

Was thanked: 169 time(s) in 132 post(s)

Hi Everybody,

Seeing some opinions expressed in the forum concerning principles for the evolution of SMath, I feel opportune to add some comments of my own.

Culturally, I’m not afraid of sometimes being wrong or to face contradictorily reasonable exchanges.

Here, I’ll go out of the forum routine to deal with some particular cases and needs.

I expect some other’s opinions and feelings targeting common progress.

I’m abundantly using SMath, since 2012.

I insist on saying that I’m very happy with the SMath as it is now, despite all its lacks, and that I profit to express here all my deep gratitude and my congratulations to Andrey and to all the developers for their work during the time that becomes so history.

For the comprehension of my sayings, I mention that I’m a senior civil structural engineer, with an engineering attitude, practice and mentality. Mainly, my concerns and my options are about the usefulness of things and actions. For me, as well mathematics as programming are important tools but not objectives.

I use SMath in my works—didactic, scientific and engineering. I published papers and books using SMath. I contribute to the evolution of the Second Generation of the European Standards, called Eurocodes, also by using SMath.

A. Based on my experience, as SMath user, I sometimes expressed some of my evaluations and proposals, not always echoed… Some of my proposals are more on the “cosmetic” side, but others touch the fundamentals. So, for instance:

i) Assenting an important virtue of SMath – that of allowing the creation of good-looking applications, I consider that it would be comfortable in use to mark graphically the limits of cells in a matrix. The subject is in a long status quo, despite my repeated demands also shared by some others.

I also proposed to provide all SMath objects with the option of being or not surrounded in a box like all the SMath native regions.

ii) SMath does not manage (as the main programming languages do) the variable scope—the accessibility mode, inside and outside the segment of variable creation.

As it is now, in a SMath function, it can be used (read) and even modified (write) a variable defined in the main segment. Any variable with the same name in the main segment and in a routine is considered as public and hence exposed to read/write operations. Of course, this feature gives the advantage of avoiding variable declaration in the entire application and of simple access.

In engineering there is used a large quantity of variables; the variables names often have précised signification (essential for a “natural” design, comprehension and communication) and therefore they can appear in many functions as local names.

The protection against unwanted interferences by the local modification of names is leading to the high loudness of the file’s design. During my entire practice with SMath, I interpreted this feature as a major (“boring”) deficiency. I understood that for certain applications this feature is a big virtue. I mention again that the major programming languages handle explicitly the scope of variables.

IMHO, the major part of engineering applications is algorithmic, including significative use of names. My main reason for using SMath is exactly based on its capability to write formulas as in literature and also to handle units.

iii) For the comfortable use of a certain category of applications, as those in engineering, I find useful the creation of a special kind of user’s defined function model, sealed, having all variables as local, the only way for external communication being read-only, at the entrance and to the output, as, for instance, those in the embedded trigonometrical functions
.

B. I hope to contribute to the idea that modern engineering could have big profits to include tools like that produced by using SMath or MathCad. I find SMath as a fitted solution for many engineering calculations.

I repeatedly mention that I do not pretend to be more reasonable than others, on the side of the actual situation assessments.

I sometimes identified a sort of simplism in some people’s comprehension of the programming design, namely by expecting the same exigences of an application during its creation as during its use. A good programming tool must facilitate both hypostases.

That’s why I point out from the start that, IMHO, the main expectation of an informatics product is the freedom of multiple choices (avoiding “dictatorial” and “monopolistic” choices, frozenly embedded by the creator).

1. During the creation of a computer application, destined for others than its creator, the “cleanness” expectance is different for the application’s creator during his work process and that of the final user. So, the final (external user) expects:

• That the informatics product to be conformed to the basics and with the recognized principles and norms concerning the subject (also called as “referential”), so that the user can adopt the soft for making his decisions and assuming responsibilities.

Here I mention that most commercial soft are built as non-transparent boxes, letting the user with the full and exclusive responsibility without access to the full transformation of input data into the output result. This situation is at least paradoxical, abnormal and even unacceptable for funding the user’s responsibilities.

• Ergonomic construction is important for productivity.

• The WYSIWYN (what you see is what you need) behavior during the soft design is a profitable tendency.

• The total transparence and accessibility of the process are the main features and advantages of SMath, constitutive for the user’s confidence.

2. The creator (designer) of an application has a very different situation and a different expectation from the tool that he uses for the fabrication of the final application.

• It can be said that the software creation is mostly an initial “dirty work.” It is iterative, a long way from trial and errors to the final production. The start priority is not oriented for the beauty side and for the apparent cleanness, but it is more oriented for the facility to catch “bugs” and to inspect the right flaw. At the same time, I do not deny that a good-looking arrangement can facilitate the work.

• In SMath, the use of “ugly colors” and borders is useful (almost indispensable) to group families of information; they contribute to the clear understanding and control of various segments in a complex application during the inception phase.

• In engineering, during the creation of an application, there is a large amount of information to be operated. Handling names without confusion is often a truly hard task. This task is very complicated by the specificity of SMath to make public the names and not to provide the encapsulation of functions.

• Some users could be interested in building their own applications by using available bricks of code.

3. I hope that my assessments are not received as offenses by anyone. For avoiding any incomprehension, I insist on saying that “my game is exclusive to the ball - as they say in football - without targeting any players’ legs”.

I beg your pardon for the length of my sayings but, as somebody said, “I did not have enough time…”.

Finally, I use Mr. Kenny Lemens’s wise adage: “May this be of Good Help”.

Best regards,
Ioan

Edited by user 04 November 2024 07:50:27(UTC)  | Reason: Not specified

Do to others as you would like them to do to you!
Knowledge is of no value unless you put it into practice - Chekhov

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline uni  
#2 Posted : 05 November 2024 21:58:54(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,614
Man
Russian Federation

Was thanked: 1368 time(s) in 802 post(s)
It happens and it is not uncommon that developers have their own vision of some things. And users just get used to it. You cannot ask Mathcad developers to change something in their interface or Microsoft in their Office. Although many users who are used to old versions of programs are unhappy with the changes that have appeared. All users are simply offered to use the existing capabilities as is. This is considered normal. I will say more, they are ready to sacrifice some users for the sake of their vision of the product. I have not used Mathcad for about 15 years, but this does not prevent it from developing. It looks beautiful, but I do not need this beauty.

Appearance has never been a top priority here. In my opinion, users are more concerned with expanding computing capabilities (including using external libraries), simplifying the document while achieving the same results, adding new graphical components for plotting graphs or simple vector graphics.
We don't even have a convention for naming functions. We don't have common approaches to the order of parameters for typical functions. Many graphical components are not brought to a common form.
But the basic functionality is satisfactory for many.
Russia ☭ forever (git.io/vOZo0)
Viacheslav N. Mezentsev
thanks 2 users thanked uni for this useful post.
on 07/11/2024(UTC),  on 12/11/2024(UTC)
Offline Davide Carpi  
#3 Posted : 12 November 2024 10:42:34(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,710
Man
Italy
Location: Italy

Was thanked: 1378 time(s) in 902 post(s)

I continue here since the XYplot thread is unrelated.

Originally Posted by: ioan92 Go to Quoted Post
@Davide,

I also use Clear, but, IMHO, the use of Clear can destroy values useful later.


I don't get this statement, I miss something maybe.
With Clear() within a procedure (a line() function) you have a granular choice of what you still want from the global context, leaving it uncleared; also everything is cleared only locally, not globally, nothing is destroyed.
If you want to use a variable name of something global "valuable", I think you should pass the value through the function arguments or name it globally differently (either way in the end at some point you should use two different names).
Also in case of a "sandbox function" you don't have any global value, unless is passed through the function arguments (still with a different name if you want to preserve the content through all the function).
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 2 users thanked Davide Carpi for this useful post.
on 12/11/2024(UTC),  on 12/11/2024(UTC)
Offline ioan92  
#4 Posted : 13 November 2024 08:39:13(UTC)
ioan92


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2012(UTC)
Posts: 93
France, Metropolitan

Was thanked: 169 time(s) in 132 post(s)
Hi Davide,

Thanks for your comments and for “provoking” me to pay more attention to the subject.

I followed, and I agreed with your arguments.

My first impression is that the problem of how SMath handles the “Variables Namespaces and Scope” is insufficiently documented. And hence derives some folklore, followed by a practice based on aping each other’s’ examples and practices (eg.- by decorating the names inside functions..). I include myself in this area of followers.

Of course, my proposal for the creation of a special user’s function, totally encapsulated, communicating read-only in the explicit input and output place, IMHO, could avoid totally and simply uncontrolled interferences.

I’m only approximately informed about the C# programming and management of the variable’s scope. I tried to understand how the subject is solved in Python language.

https://www.programiz.co...on-programming/namespace
Here is a synthesis of their vision:

Python-Scope.jpg

Here there are some explanations about their strategy:

https://realpython.com/python-scope-legb-rule/
This is LEGB rule:

LEGB stand for Local, Enclosing, Global, and Built-in scopes.

Local (or function) scope is the code block or body of any Python function or lambda expression. This Python scope contains the names that you define inside the function. These names will only be visible from the code of the function. It’s created at function call, not at function definition, so you’ll have as many different local scopes as function calls. This is true even if you call the same function multiple times, or recursively. Each call will result in a new local scope being created.

Global (or module) scope is the top-most scope in a Python program, script, or module. This Python scope contains all of the names that you define at the top level of a program or a module. Names in this Python scope are visible from everywhere in your code.

Built-in scope is a special Python scope that’s created or loaded whenever you run a script or open an interactive session. This scope contains names such as keywords, functions, exceptions, and other attributes that are built into Python. Names in this Python scope are also available from everywhere in your code. It’s automatically loaded by Python when you run a program or script.

The local scope or function scope is a Python scope created at function calls. Every time you call a function, you’re also creating a new local scope. On the other hand, you can think of each def statement and lambda expression as a blueprint for new local scopes. These local scopes will come into existence whenever you call the function at hand.

By default, parameters and names that you assign inside a function exist only within the function or local scope associated with the function call. When the function returns, the local scope is destroyed and the names are forgotten.”

It seems that you mean that by using “Clear Function” it could fully force the local scope into an implicit declaration?

For a better assessment of the subject, I imagined some simple exercises:

Scope-Ioan.sm (58kb) downloaded 3 time(s).

These examples show some simple sources "to build the hell".

The situation makes me think of the French sentence:
“Ne mêlez jamais les serviettes et les torchons”. (Never mix the tea towels and napkins.)

Finally, it seems to me that the solution I’ve proposed still deserves some attention as a solid issue.

I understood that this can’t have a “plug-in” solution. I’d like to know how Andrey sees the subject.

Python's solution is a clever solution (?!)

Best regards,
Joan



Edited by user 14 November 2024 02:56:05(UTC)  | Reason: Not specified

Do to others as you would like them to do to you!
Knowledge is of no value unless you put it into practice - Chekhov
Offline Kenny Lemens  
#5 Posted : 23 November 2024 12:23:25(UTC)
Kenny Lemens


Rank: Advanced Member

Groups: Registered
Joined: 11/01/2018(UTC)
Posts: 149
Man
United States
Location: Wisconsin

Was thanked: 71 time(s) in 45 post(s)
Greetings,

Originally Posted by: ioan92 Go to Quoted Post
Finally, I use Mr. Kenny Lemens’s wise adage: “May this be of Good Help”.
I am humbled that you consider my complimentary close as a wise adage.


As to the overall conversation: I understand your critique. To assist your understanding of SMath as it currently is, please review the following:
Click to enlarge

You will notice that it isn't as "clean" as you might have expected. I would contend that there are at least four layers:
  1. Built-in
  2. Global - Worksheet (as datatype: 'absolute variables exist' )
  3. Enclosed - Worksheet (standard variables/units as we know them)
  4. Local (those declarations trapped within a Function)

It is not 'clear cut' as you can 'escape' a given layer/namespace depending on the technique used.

On a tangent; you said that you only have a brief knowledge of C#: C# is an object-orientated language. This means that a function can be strictly 'local' as you know it, or a function can REFERENCE objects that are on the global level, and thus modify them. If you are interested, research terms like 'Public'; 'Private'; 'Shared'; and 'Friendly' to understand the caps/limits object-oriented namespaces can be interacted with.


May this be of Good Help;
⚜ Kenny Lemens, P.E. ᵂᴵ
"No matter where you go, there you are." -Buckaroo Banzai

Hotkeys: https://en.smath.com/for...rce.ashx?a=45771&b=2
thanks 2 users thanked Kenny Lemens for this useful post.
on 24/11/2024(UTC),  on 24/11/2024(UTC)
Offline ioan92  
#6 Posted : 24 November 2024 08:20:46(UTC)
ioan92


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2012(UTC)
Posts: 93
France, Metropolitan

Was thanked: 169 time(s) in 132 post(s)
Greetings from Paris!

1. Thank you for your kind attention and for your interesting answers.

2. I mention again, if necessarily, that my “provocation” was not intended as centered on myself as an individual, but more on my perceptions during the 12 years of using SMath. I expected to see if I also have some “accomplices” …
In fact, I’m fully surprised and, in a way, disappointed about the big silence on my proposals because my sincere intention was not to make a “diversion” in a calm place.

3. I included some information about me, only for a better comprehension of my potential specificities and limits, with declared and sincere humility. As a lateral complementarily information, I started, a long time ago, my “programming career” with Fortran IV and I ended it later with MS Visual Basic 6. Modestly, I kept my curiosity about some trends in the programming world. Humbly, I also have a certain vision, even of what object programming means and even of the encapsulation’s meaning; I also heard about some concepts like containerization, inheritance and abstraction.
I like this general (OOP) text:
“Encapsulation is a way to restrict the direct access to some components of an object, so users cannot access state values for all of the variables of a particular object. Encapsulation can be used to hide both data members and data functions or methods associated with an instantiated class or object.”

In my mind, the user’s functions are more like objects, there from my expectations for encapsulation. Python seems as using this strategy (?).

4. For our time, the wheel, the fire and other essential ideas are already discovered; so that when we face a “new” situation, we try to identify the presence of great associated findings, already available. So is the case of some concepts you mentioned as “Public”, “Private” etc. You can add some basics like “By Value” and “By Reference”.

5. From your text, it appears that you caught the true strategies of SMath, with full details on subjects like namespaces & scope. For me, the subject is not targeted as an intellectual objective, but it is a major practical condition.

6. Based on the lack of available specific information, I expect to understand if the SMath solution is similar to an existing system or it is a totally brand new one. In the post #4, in order to stimulate the information exchange, I show very briefly my comprehension of Python solutions. The subject is abundantly present on the net what signifies, to me, its importance and difficulty.

7. Thanks for illustrating your vision of the SMath case “as it currently is”. I willingly confirm that IMHO the subject “isn’t as ‘clean’ as you might have expected “. Also, I’m curious where from you “discovered” all these real design features of SMath? Only by intuition, by effects comparison or from some special sources? I’m not able to identify your vision in the “classics”; of course, it’s only my simple personal limits the true reason.

8. Seeing all your information, I’m still expected your explicit proposals concerning my precise “claims”. Is it only a problem of my personal insufficient understanding of the basics or it is also a potential problem for the improvement of the SMath soft itself. The first case is the simplest to solve by adding some didactics.

9. My pragmatic interrogation is if, by using your actual explanations, I can avoid my blocking situations, and especially I ask how to do this. As for now, even by counting on your lights, I’m not sure how do I proceed to “improving my professional life comfort”?

10. For instance, in my post #4, there is this example:

bonzai.png

That drives me nervous. Why the “h” variable was modified; I had never modified it inside the function??? It seems that variables are manipulated “By Reference” and not “By Value”??? Inside the function, I cleared all, including the function’s parameters (as Davide suggested). Of course, the example is a little bit twisted.

11. In the context I keep my opinion that, by the simple introduction of a kind of special user’s function, totally encapsulated, all my problems will be vanished, without attempting the other’s happiness built on using things as they are now. That’s my true and maybe only problem on which I expect some positioning. Of course, I do not pretend as being right, but I expect arguments and especially solutions.

12. I remember with nostalgia the useful Fortran’s statements like “Common”, “Block Data” “External” that helped with a clean code.

Regards,
Ioan

“A Bon Entendeur, Salut!”

Edited by user 24 November 2024 08:42:34(UTC)  | Reason: Not specified

Do to others as you would like them to do to you!
Knowledge is of no value unless you put it into practice - Chekhov
thanks 1 user thanked ioan92 for this useful post.
on 24/11/2024(UTC)
Offline mkraska  
#7 Posted : 24 November 2024 11:21:44(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 2,035
Germany

Was thanked: 1167 time(s) in 746 post(s)
Greetings from Potsdam,

Since the very beginning of my SMath experiments I am missing an official specification on how SMath is expected to behave. This is not nessecarily the same as the actual behaviour, as there can always be bugs. But without a specification you never know whether something is a bug or a feature or just wrong understanding of the feature.

Is it really by intent, that we (seem) to need these ugly name decorations inside function definitions to avoid accidental interference of name spaces? This doesn't really contribute to readability of the programs.

The h problem in your example: Is that intended behaviour or is this a bug?

I guess that most of the users which could break the silence here, just refrain from making possibly useless noise by guessing what could be the intent. The wish for reliable specifications has been frequently expressed in the forum and there is no reason to assume that Andrey isn't aware of this.

Missing specification and documentation is a typical feature of hobby projects. It is more fun to get things to work than to explain and document them. There is no instant gratification for the latter. In my own handbook attempts I always feel like on thin ice when it comes to variables and scoping.

Even Valery Ochkov, who is publishing on SMath at a remarkable pace, seems to rely on trial and error when it comes to find out how things work.

Once SMath becomes important as a commercial product and a serious import substitute for Mathcad in Russia, I expect the pressure in that direction to rise and eventually to give results.

Sorry for just making some noise.

Martin






Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 24/11/2024(UTC)
Offline ioan92  
#8 Posted : 24 November 2024 20:40:50(UTC)
ioan92


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2012(UTC)
Posts: 93
France, Metropolitan

Was thanked: 169 time(s) in 132 post(s)
Hi Martin,

Thanks for your return and a big thank for all your well-known contributions for the SMath's good use and progress.

I fully agree with your observations.


Originally Posted by: mkraska Go to Quoted Post
Greetings from Potsdam,
The h problem in your example: Is that intended behaviour or is this a bug?


The case starts as a "bug" but later I used it to illustrate something that isn't explicitly said, namely the fact of "By Reference" use for variable names, inside the functions.

My "shout" starts from the wise idea that once a problem is well enough defined, it is already solved, in half.

Sometimes, "the noise" can be profitable to signalize dangers.

As I repeatedly said, I do not exclude being wrong on some sides, but I sincerely hope that, with more opinions, some advances could be possible and even probable.

Have a good day,
Ioan


Edited by user 24 November 2024 20:46:34(UTC)  | Reason: Not specified

Do to others as you would like them to do to you!
Knowledge is of no value unless you put it into practice - Chekhov
Offline Davide Carpi  
#9 Posted : 25 November 2024 04:16:29(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,710
Man
Italy
Location: Italy

Was thanked: 1378 time(s) in 902 post(s)
I don't think there is a provocation; the program lacks documentation and there are hidden features that might be forgotten or overlap easily.

I have still this around, but seems it is outdated in some parts, since some changes were made along the road: User-defined Functions in SMath Studio (rev.8).sm (294kb) downloaded 2 time(s).

Your example has several things inside it, looking by small bits.


  • Clear(...)

    here you are clearing all variable names. Since a and b are variables passed by the function on the LHS, these are cleared as well. This means all calculations involving these variables are made simbolically.
    2024-11-24 15_57_16-SMath Solver - [rect.sm_].png
    As you can see (now) the result doesn't replace the local variables because SMath recognize that the local a is not the global a (previously it would have been replaced by the global a value once exposed to the canvas).

  • b:k.b*b

    That's not as straightforward as before, but with line() you can pass back variables to the canvas (as official feature, there is some post by Andrey somewhere); if you redefine a LHS variable name inside the line(), this change will be passed back to the canvas, using the input name canvas side.
    2024-11-24 15_40_13-SMath Solver - [User-defined Functions in SMath Studio [rev.8].sm].png

    Here it seems the Clear() effect doesn't apply neither on the direct call (e.g. Clear(a,b) has not cleared the inputs b and h) nor in the redefinition (global_h after the function call is not exposed_local_k.b*exposed_local_b but is global_k.b*global_b).
    2024-11-24 16_00_55-SMath Solver - [rect.sm].png

    Clear() behaviour aside, the point is that inside line() you shouldn't redefine a variable passed as argument by the LHS function.
    I think is also bad as practice, since k.b*b it should have another name (b',b*,...) since is another parameter (but I understand the frustration).

  • twist in variable names (global vs local); this seems it is handled correctly (this is what introduced the change in exposed_local vs global observed in the first point above).
    2024-11-24 16_06_13-SMath Solver - [rect.sm_].png



I also think a different sealed function would be a good tool to have. About Kenny's layers I understand it, but probably anything "above the canvas" could be safely considered a "superglobal" by the users, and therefore by such sealed function.

Edited by user 25 November 2024 05:00:55(UTC)  | Reason: typo

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 2 users thanked Davide Carpi for this useful post.
on 25/11/2024(UTC),  on 25/11/2024(UTC)
Offline ioan92  
#10 Posted : 25 November 2024 05:57:07(UTC)
ioan92


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2012(UTC)
Posts: 93
France, Metropolitan

Was thanked: 169 time(s) in 132 post(s)
Hello,

Thanks for answering my “non-provocation”. Thanks for your attention and for your patience, commonly respected in this forum.

I have no doubt that, behind SMath operations, there is some logic, potentially accessible to even ordinary users like me. I recognize that it’s hard enough for me to follow totally the nice debugging process you developed. However, I think it is a thousand times better to be able to get rid of this type of situation due to the existence of more robust programming rules ( ?!).

Such a simple partial solution could be the creation of a new type of user function, completely sealed, like the trigonometric functions of the system. I understand that you also agree with this proposal.

Of course, my example is deliberately provocative, but it also shows how one can "build a calvary in a hospital".

If, for every use, we must consider a debugging operation like yours, I fear that there rests no longer a great attraction to this software.

I’m still unclear why there is no larger participation around my proposals.

I suppose that my free tone could be a reason. On the other side, I prefer the adage “The silence means agreement”.

PS:
I wonder if in the SMath processing, the named symbolic or numerical optimization, is not similar to the classical options “By Reference” and “By Value” ?

I review your tutorial on user's function. Your examples include some compact cases when the separation of global variables is simple enough.

In some complex applications, things are much harder to manage and variable's kind is more complicated to isolate and to follow (?).

Thanks again,
Ioan

Edited by user 25 November 2024 07:32:41(UTC)  | Reason: Not specified

Do to others as you would like them to do to you!
Knowledge is of no value unless you put it into practice - Chekhov
Offline mkraska  
#11 Posted : 25 November 2024 11:16:54(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 2,035
Germany

Was thanked: 1167 time(s) in 746 post(s)
If you highlight a variable inside a line block and press F12, then the cursor jumps to where the value is defined
1. if then the cursor jumps to the parameter list on the left hand side of the function definition, this reminds you that it is a parameter of the function
2. if the cursor remains where it is, then it it is a reference to an undefined global
3. if the cursor jumps to somewhere inside the function, then it is a true local variable.
4. if the cursor jumps to somewhere outside the function, then it is a defined global variable, yet the value is ignored at storage time, as can be seen from the preview of the stored expression. This is actually the same result as in case 2

Clear() is ignored by this mechanism. I.e. if you have a local Clear, this should be the jump target.
Also, if you use the name of a local variable of a definition on the canvas outside, F12 jumps to the definition of that variable inside the function definition. That is definitely not correct if whatever you define inside the function is local (unless it is in the parameter list).

Here are some examples of F12 jumps. Those which I understand are in green, those which not, are in red. In f(a,b ) I actually use the long standing Clear() trick by Davide, which actually seems to be more reliable than the new built-in version. Yet it is over-greedy, as it deletes d also in the global scope, which should not happen by a definition inside a line block function.

2024-11-24 23_25_12-SMath Solver - [TM2 09 04.sm_].png

Would perhaps helpful if the various situations could be marked by coloring the variables. All variables that could be taken from the outside could be in red.
All variables from the paramter list could be in blue.

Edited by user 25 November 2024 12:02:30(UTC)  | Reason: Not specified

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 4 users thanked mkraska for this useful post.
on 25/11/2024(UTC),  on 25/11/2024(UTC),  on 25/11/2024(UTC),  on 26/11/2024(UTC)
Offline ioan92  
#12 Posted : 26 November 2024 22:29:42(UTC)
ioan92


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2012(UTC)
Posts: 93
France, Metropolitan

Was thanked: 169 time(s) in 132 post(s)
Hi Davide, Martin and Kenny,

All my gratitude for reviewing some aspects of the specific SMath Debugging Process.

Almost all programming languages include debugging procedures. SMath, owing a high transparence and friendly design process, is naturally less indebted to an eventual debugging process. A special case is inside functions.

As about trace() using practice, in the case of a complex application, things are not more so easy. IMHO, an excessive use of debugging risks to kill the major SMath’s singularity – that of simplicity and transparency.

It appears that the very basics of SMath are poorly documented and also not enough retrieved in the Forum. I feel it as a major weakness and a mission to be accomplished.

Looking around some present exchanges, I feel stimulated to observe my naïve use of variables, far from SMath’s native assumptions.

Synthetically, if I’m not wrong, we can say that any variable used on canvas, outside user functions, behaves as global (accessible allover in read/write; including modifiable, with consequences overall in its instances - local or global) over the entire application (including inside user functions).

On the contrarily, inside any function body, all variables which aren’t already used as global (this is identical as being explicitly declared) are only local, without diffusing values into the main application, nor into other users’ functions.



Davide, Martin and Kenny, please correct my assertions if necessarily.

In this context, it appears to me as more logical (?) to “decorate” only the global variable names; this also leads to the idea of using as few as possible global variables (provided, if necessarily, as a precaution, with “decorated” names, instead of an explicit scope declaration).

The local names used inside user functions keep totally the feature of being “sealed” (valid only inside the function) with a full independence of variable content in each function, as long as they do not become “global”. I’m not very sure if a variable used as a function return becomes so “global” (as if declared, “By Reference”)???

A special case is of the applications without user functions. Here the "decorations" are not indicated; all variables are as global.

If what I’ve said here is true and clearly explained to users, there is no more reason to modify the core program.

However, I maintain my proposal on the utility of the creation of a special kind of user function, totally encapsulated.

I wait for some critical reactions and especially proposals about my observations.

PS:
This example shows that if the parameters of a function are modified inside the function, the global values of parameters will be changed:

Ioan26112024.sm.png

what can complicate the use.

That's a suplementarily reason for the use of an encapsulated type of function.

Best regards,
Ioan

Edited by user 27 November 2024 03:19:28(UTC)  | Reason: Not specified

Do to others as you would like them to do to you!
Knowledge is of no value unless you put it into practice - Chekhov
Offline mkraska  
#13 Posted : 27 November 2024 06:25:55(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 2,035
Germany

Was thanked: 1167 time(s) in 746 post(s)
Originally Posted by: ioan92 Go to Quoted Post

PS:
This example shows that if the parameters of a function are modified inside the function, the global values of parameters will be changed:

Ioan26112024.sm.png

what can complicate the use.

That's a suplementarily reason for the use of an encapsulated type of function.


I don't mind functions using the arguments as output channels (call by reference). E.g. if handling big data, modifications in-place might be more efficient than to create deep copies. If you don't want that to happen, you just don't assign to the formal arguments inside the function.

I am much more concerned about the problem in my above example, where I assign to a variable which is not on the parameter list and have a side effect to the global context. Thus it is not safe to use this function in a context where d has a value. It should not require knowledge about internal naming in the functions implementation to make safe use of a function.

I could perhaps accept that the global context is visible inside the function, but that should be in a strict read-only way.
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 27/11/2024(UTC)
Offline ioan92  
#14 Posted : 27 November 2024 08:07:08(UTC)
ioan92


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2012(UTC)
Posts: 93
France, Metropolitan

Was thanked: 169 time(s) in 132 post(s)
Originally Posted by: mkraska Go to Quoted Post

I could perhaps accept that the global context is visible inside the function, but that should be in a strict read-only way.


Thanks for the return.
I agree your observations.
I extended a little my example:

Ioan26112024b.png


1. I understood that the names in the call line are global names.
2. I copied the input variables as local names, inside the function.
3. Without being alterated inside the function, the input names values seems saved against inner uses.
This seems good news (!?)
4. The input variables copy rest invisibles outside the function.
5. As a principle, any global variable is totally accessible (read/wrote) in all the functions existing on the canvas. Therefor my proposals to give "decorated" names to global variables.

However I'd prefer the special encapsulated function. This leads to less precautions.

Allover, it seems that some strategies are available, once the user is advertised on the basics.

Edited by user 29 November 2024 04:23:40(UTC)  | Reason: Not specified

Do to others as you would like them to do to you!
Knowledge is of no value unless you put it into practice - Chekhov
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.