fxm wrote:For the variables defined in a namespace block or the static member variables in an UDT, the keywords "Typeof()" or "Sizeof()" require double parentheses around the names (with the structure name as prefix)
- (see previous post)
fxm wrote:For the variables defined in a namespace block or the static member variables in an UDT, the keywords "Typeof()" or "Sizeof()" require double parentheses around the names (with the structure name as prefix)
fxm wrote:fxm wrote:For the variables defined in a namespace block or the static member variables in an UDT, the keywords "Typeof()" or "Sizeof()" require double parentheses around the names (with the structure name as prefix)dkl, must I fill a bug report?
- (see previous post)
- On a similar subject, why the compiler can not return (through 'Typeof()') the types of any non-static members within TYPE/UNION?dkl wrote:No, it already exists: #404
Code: Select all
Dim As Double D
Declare Sub S (Byval As Byte)
Namespace N
Dim As Double ND
Declare Sub NS (Byval As Byte)
End Namespace
Type T
Dim As Double TD
Static As Double TSD
Declare Sub TS (Byval As Byte)
Declare Static Sub TSS (Byval As Byte)
End Type
Union U
Dim As Double UD
Static As Double USD
Declare Sub US (Byval As Byte)
Declare Static Sub USS (Byval As Byte)
End Union
#print typeof(D)
#print typeof(@S)
#print typeof(N.ND) '' (error 41: Variable not declared, except with double parentheses)
#print typeof(@N.NS)
#print typeof(T.TD) '' error 208: Illegal non-static member access
#print typeof(T.TSD) '' (error 41: Variable not declared, except with double parentheses)
#print typeof(@T.TS) '' error 208: Illegal non-static member access
#print typeof(@T.TSS)
#print typeof(U.UD) '' error 208: Illegal non-static member access
#print typeof(U.USD) '' (error 41: Variable not declared, except with double parentheses)
#print typeof(@U.US) '' error 208: Illegal non-static member access
#print typeof(@U.USS)
Code: Select all
Namespace One
Dim As Integer I1 = 1
Declare Sub s ()
Type UDT
Dim As Integer I2 = 2
Static As Integer I3
Declare Sub s1 ()
Declare static Sub S2 ()
End Type
End Namespace
Using One
Sub s ()
Print "One.s()"
End Sub
'Dim As Integer UDT.I3 = 3 '' error 131: Declaration outside the original namespace
Dim As Integer One.UDT.I3 = 3 '' full name is mandatory
'Sub UDT.s1 () '' error 131: Declaration outside the original namespace
Sub One.UDT.s1 () '' full name is mandatory
Print "One.s1()"
End Sub
'Sub UDT.s2 () '' error 131: Declaration outside the original namespace
Sub One.UDT.s2 () '' full name is mandatory
Print "One.s2()"
End Sub
Print I1
S()
Dim As UDT u
Print u.I2
Print u.I3
Print UDT.I3 '' works
u.s1()
u.s2()
UDT.s2() '' works
I think the term: definition, is ambiguous and better replaced with: implementation.coderJeff wrote: The error message is not wrong, though some might split hairs over the difference between declaration versus definition.
But that works for a non-member procedure declared in a Namespace but outside implemented through a 'Using namespace_name':coderJeff wrote:This seems like it should be the normal behaviour and correct that the definition should be fully qualified, either inside a namespace block, or with the namespace identifier prefix
Code: Select all
Namespace One
Declare Sub s ()
End Namespace
Using One
Sub s ()
Print "One.s()"
End Sub
Oh, that is weird. I would have expected 'sub s()' to be defined in the global namespace instead of namespace One.fxm wrote:But that works for a non-member procedure declared in a Namespace but outside implemented through a 'Using namespace_name':Code: Select all
Namespace One Declare Sub s () End Namespace Using One Sub s () Print "One.s()" End Sub
Code: Select all
Namespace One
Declare Sub s()
End Namespace
Using One
declare sub s()
s()
One.s()
'' undefined reference to `S@0'
'' undefined reference to `ONE::S()@0'
One aspect of the using directive may seem slightly counterintuitive at first. The visibility of the names introduced with a using directive is the scope in which the directive is made. But you can override the names from the using directive as if they’ve been declared globally to that scope!
Code: Select all
namespace one
declare sub s() '' declaration only
end namespace
using one
sub s() '' definition (and declaration?)
end sub
Code: Select all
namespace one
declare sub s1()
declare sub s2()
end namespace
using one
sub s1() '' definition of one.s1()
end sub
declare sub s1() '' .s1() declared in the scope overrides one.s1()
sub s1() '' OK, definition of .s1()
end sub
sub s2() '' definition of one.s2()
end sub
''declare sub s2()
sub s2() '' error 4: Duplicated definition
end sub
Code: Select all
Namespace One
Namespace Two
Declare Sub s1 ()
End Namespace
Type UDT
Declare Static Sub S2 ()
Dim As Integer __
End Type
End Namespace
Using One.Two '' One.Two is a namespace
Using One.UDT '' One.UDT is not a real namespace => error 3: Expected End-of-Line
Code: Select all
Namespace One
Dim As Integer I1 = 1
Sub s1 ()
Print "One.s()"
End Sub
Type UDT
Dim As Integer I2 = 2
Declare Sub s2 ()
End Type
Sub UDT.s2 ()
Print "UDT.s2()"
End Sub
' Print I1 '' error 122: Illegal inside a NAMESPACE block
' s1() '' error 122: Illegal inside a NAMESPACE block
Dim As UDT u
' Print u.I2 '' error 122: Illegal inside a NAMESPACE block
u.s2() '' OK ???
End Namespace
As far as I know, there is no equivalent to the fbc examples given for this behaviour in C++. The current results for fbc are kind of all over the place. My personal opinion is that USING should be for access only, not definition.fxm wrote:Referring to the behavior described for C ++ (see my previous post), the following seems normal to me:
Code: Select all
Namespace One: declare sub s() :End Namespace
Namespace Two: declare sub s() :End Namespace
Using One
Using Two
sub s() '' defined as Two.s() - must check asm/c output to see. But why?
end sub
s() '' ambiguous symbol access
Code: Select all
declare sub s()
sub s()
end sub
Namespace One
declare sub s()
End Namespace
Using One
sub s() '' duplicate defintion? Why?
end sub