Code: Select all
Procedure T()
Static *Table.Character = ?Table
Table:
EndProcedure
Code: Select all
Procedure T()
Static *Table.Character = ?Table
Table:
EndProcedure
That's not true, this works:Kaeru Gaman wrote:but since the compiler works one-pass, adresses of labels later in the code can't be known in this step.
Code: Select all
Debug ?Label
Label:
It also works like this:eesau wrote:That's not true, this works:Kaeru Gaman wrote:but since the compiler works one-pass, adresses of labels later in the code can't be known in this step.
... because it's FASM that gets the address, not PB. Also, Trond's code works if Protected is used.Code: Select all
Debug ?Label Label:
Code: Select all
Global *Table.Character = ?Table
Procedure T()
Shared *Table.Character
Table:
EndProcedure
Code: Select all
Procedure T()
Static *Table.Character
If *Table = 0
*Table = ?Table
EndIf
Table:
EndProcedure
No, it is in fact directly limited by labels. I don't understand what you're saying. It works with every other constant in scope except labels.The hangup is that Static can only accept a literal or defined constant. If it could accept a computed constant (determined at compile time) it would work with your first example Trond. It isn't directly limited by label's.
Code: Select all
Procedure Test()
Static M = #PI + 5.5
EndProcedure
They are not variables! They can't ever vary, they are constants. And since they are determined at compile time there is no real reason they can't be used with Static variables.Label's fall into the category of a variable whose value is determined at compile-time.
Trond wrote:No, it is in fact directly limited by labels. I don't understand what you're saying. It works with every other constant in scope except labels.The hangup is that Static can only accept a literal or defined constant. If it could accept a computed constant (determined at compile time) it would work with your first example Trond. It isn't directly limited by label's.
See?Code: Select all
Procedure Test() Static M = #PI + 5.5 EndProcedure
They are not variables! They can't ever vary, they are constants. And since they are determined at compile time there is no real reason they can't be used with Static variables.Label's fall into the category of a variable whose value is determined at compile-time.
Code: Select all
m = #MyConstant + 5.5
#MyConstant = 12
Code: Select all
m = ?Table + 5
DataSection
Table:
Data.l 1,2,3
EndDataSection
You can get the actual facts from the asm file, and your description of what happens isn't right. There is no space allocated to store the value of the label.*Disclaimer: the following details about PureBasic are theorized and not known as fact.
Code: Select all
var = ?label
label:
Code: Select all
mov dword [v_var], l_label
l_label:
Code: Select all
mov dword [v_var], 123
Code: Select all
mov ecx, dword [v_othervar]
mov dword [v_var], ecx
Code: Select all
s_Procname.v_varname dd 123
Code: Select all
s_Procname_v_varname dd l_nameoflabel
Which is why I posted this in a forum called "Feature Requests and Wishlists".I think what you are needing is a feature request.
I agree. I think if this was implemented as you described it would take some of the rough edges off that are still present with using labels.Trond wrote:When the compiler sees (Static varname = 123) it currently writes this to the near end of the asm file:All that is needed to support this feature is to replace ?nameoflabel (used instead of 123) with l_nameoflabel for (Static varname = ?nameoflabel):Code: Select all
s_Procname.v_varname dd 123
In that case it would work.Code: Select all
s_Procname_v_varname dd l_nameoflabel
Which is why I posted this in a forum called "Feature Requests and Wishlists".I think what you are needing is a feature request.