Page 1 of 1

public variables yes or not

Posted: Wed Sep 23, 2020 7:27 am
by Otto
copied from SLACK - Google translation
Best regards,
Otto


public, private, local and thread static

and remember the modified hbclass.ch

if classes are going to be used

ok

Neu

Osvaldo Ramirez 23:18 Uhr
Just as a note: a static thread is: "STATIC <xVar>" and it will depend on whether that variable is public or private; it is said to be published
when its declaration is outside of any procedure / class or function; it is said private when its declaration is inside a procedure / class or function;
Is my assessment correct?

Now, what problem exists without a static is public? Can you see it in any PRG you run?

You mixed like different concepts

Explain me please.

Static variables are visible only within prg where they are declared

The privates are visible from the moment they are declared onwards to their execution

The publics are visible throughout the program

Locals only within your function where they are declared

I see that we can use all types of variables in modharbour?

of course

But static seems a bit dangerous to me

Because we don't have an exe and on every call

Cesar SysCtrl Software
// {% LoadHrb ('lib / tweb.hrb')%} function main ()
PUBLIC hVars: = {=>}
? 'Version:', twebversion () retu nil

They can be seen differently
Cesar SysCtrl Software 01:59 Uhr
this works fine!

So other prg

Clear

What if

I hope the variable purists don't jump around our necks ha ha ha
02:02 Uhr
Sorry good night Cesar


Angel Pais 02:11 Uhr
You must bear in mind that these are not compiled programs but quasi-interpreted

So the behavior is more similar to what dbase was where there were only public and private variables

The usefulness of statics is highly debatable in this type of program and they are also shared between threads when there are simultaneous requests

Therefore, if you find it absolutely necessary to use them, use static threads, which vanish when the current thread ends, as well as being only visible in the current thread

Good point Angel
Cesar SysCtrl Software


I'll start with the public