Would be very useful in my current PB project.

Show us how that would look like in C and I'm sure someone can answer that question.Blood wrote:Can i make a request for the static keyword to be overloaded to create global variables with source file scope like C?
Code: Select all
static void foo();
Yes! It would provide a simple namespace for source files. For example, you could define lots of global variables in one source file that work with particular procedures in that source file. When this source file is included into another, that file cannot see the static globals in the included one. Also for procedures, you could create ones that are hidden from other source files, etc.. Very useful IMHO.milan1612 wrote:In C the static keyword serves two purposes. Firstly the one we know from Purebasic inside
Procedures, and secondly, when used on global variables outside any procedure the 'static'
means that only the functions within the same sourcefile have access to it. This even
works for functions themselves, e.g. a function declared like this:can only be used within the sourcefile it exists.Code: Select all
static void foo();
That's a very useful 'scope-limiting' feature!
I can't agree more to this! Actually, the idea to mimic C in this case is a very good one, becauseBlood wrote:At the minute everything is lumped together.
Code: Select all
Workspace apple
;
a.f = 1
;
Workspace pear
;
a.f = 1
;
Code: Select all
Local a.f
Global b.f
Code: Select all
Local a.f
Global b.f
Universal c.f
Beyond d.f
Code: Select all
Workspace apple
;
Beyond a.f = 1
Global b.f = 2
;
Workspace pear
;
a.f = 3 ; would affect a.f in all workspaces
Global b.f = 4
;
Debug a.f ; returns 3
Debug apple:b.f ; returns 3
Debug b.f ; returns 4
Debug pear:b.f ; returns 4
Yupblueznl wrote: Well, I'd like 'modules' or 'workspaces' better, I think this discussion took place once before...
Does this mean that included source files would not 'see' the same value of the variables that the main line source would see? Or that variable would be separate for included source?secondly, when used on global variables outside any procedure the 'static' means that only the functions within the same source file have access to it.