(environment: windows 7 64 bit (but using .net 32 bit) - using "Cobra 2010-10-18" modified to use .NET 4.0 using ildasm-ilasm (option 4 by RIGHT_THEN)
I think this topic has been already discussed, but didn't really find a simple YES/NO answer.
Is it possible to declare a class shared with all its members shared as well?
The code below declares an instance class with only shared members and correctly compiles:
use System
class Greet
var name as String is shared
cue init is shared
#base.init
.name = "carlos"
def salute is shared
print "Hello [.name]!"
# Greet the world!
class GreetProgram
def main is shared
pass
if I add "is shared" to the class to make it a pure static class then I get a compile error
use System
class Greet is shared
var name as String is shared
cue init is shared
.name = "carlos"
def salute is shared
print "Hello [.name]!"
# Greet the world!
class GreetProgram
def main is shared
pass
The error is:
C:\Cobra\bin40>cobra.exe test2.cobra -ref:System.Numerics.dll
c:\Cobra\bin40\test2.cobra(4): error: "Greet._ih_invariantGuard" : impossible de
déclarer les membres d"instance dans une classe static
Compilation failed - 1 error, 0 warnings
Not running due to errors above.
(impossible to declare instance members on an static class)
Thanks in advance.