Local labels and DataSection

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Local labels and DataSection

Post by User_Russian »

In my opinion, if DataSection located in procedure, labels have to be local, not global.
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Local labels and DataSection

Post by skywalk »

The same happens if you define a Structure inside a Procedure. Structures are global.
Labels inside procedures are local, but labels inside DataSections(no matter where defined) are global.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Local labels and DataSection

Post by User_Russian »

If DataSections, is inside a procedure, it implies that the contents need only within the procedure. It means there is no need for global label.

By the way, a good idea. If the structure constant, or interface, etc., are declared inside a procedure, it suggests that they are necessary only in this procedure and the procedure to be limited to them namespace.
TheoGott
New User
New User
Posts: 7
Joined: Wed Oct 16, 2013 10:37 am

Re: Local labels and DataSection

Post by TheoGott »

The compiler could transparently (internally) add ad [procedurename_] to the datasection-label. This way it could be treated as global while beeing local from standpoint of the programmer. He could use a Macro, or could always use the same Label Name in different procedures or global.
Post Reply