[Implemented] Global procedure parameters

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

[Implemented] Global procedure parameters

Post by BackupUser »

Restored from previous forum. Originally posted by horst.

Example:

Code: Select all

Global bla

Procedure Test(bla) 
n = bla*2
ProcedureReturn n
EndProcedure 

bla = 12
result = Test(100)
 
The result will be 24.

Wouldn't it be better if Purebasic refused procedure parameters
that have been defined as Global ????

I see no reason why anybody would do this intentionally, but it
could cause a lot of problems if done accidentally.


Horst
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Hi Horst,
if you use a procedure as thread and you work with global variables (to act differently in the thread if they change), you need access to these global variables...
Just use different names inside procedures if you want to capsulate them.



Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by horst.
if you use a procedure as thread and you work with global variables (to act differently in the thread if they change), you need access to these global variables...
I don't quite understand.
Do you mean there are cases where an argument
in a prodedure definition must be a global variable?
Just use different names inside procedures if you want to capsulate them.
I just would appreciate if Purebasic would locate things
that defenitely must be errors.


Horst
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
I don't quite understand.
Do you mean there are cases where an argument in a prodedure definition must be a global variable?
Horst
No.

Hmm, suppose I didn't catch your wish in the first place, sorry.
I meant that you need access inside a procedure to global parameters.

But you don't want to restrict all the global parameters inside procedures, only the ones that are used as an argument in a prodedure definition.

OK, I got it. Sorry for my misunderstanding.
Well it's Friday morning, and I didn't slept well...


Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
Post Reply