Glad you like Cobra. Lots of info for you:
So Thread.sleep takes an int which 32 bits, but the use of sw.elapsedMilliseconds is causing a conversion to long/32-bits. I wrapped the expression in parens and cast to int:
Thread.sleep((.sleep_time - sw.elapsedMilliseconds) to int)
You could say it's poor API that sw.elapsedMilliseconds is 64-bits and Thread.sleep is 32-bits.
So to look up something like Thread.sleep, I just google "msdn thread sleep". You can also go to the MSDN web site and search for "thread sleep".
I prefer "col.bacteria.clone" over "col.bacteria[:]", but that's just style choices.
For smaller code like:
if ref_twin
.twin = ref_twin
You can put on one line:
if ref_twin, .twin = ref_twin
A statement like:
controller as Controller = Controller()
can just be:
controller = Controller()
I'm not sure why you're using threads as Thread.sleep here as it doesn't look necessary, but maybe your program is not complete yet, or maybe I missed something. I think you can use Thread.sleep even without spawing an explicit thread.
Regarding dir(obj), .NET/Mono provides similiar functionality through "reflection". For example, "obj.typeOf.getMembers" will return a list of the members of that type including methods, fields/vars, etc. You can loop through them and ask each member for its name. You can also get just methods, or just variables, or just declared with no inherited members, etc. Lookup ".NET reflection" for more info. Here is a sample program I cooked up:
class A
var myField = 1
get myProperty as int
return 2
get [i as int] as int
return i*2
def myMethod
pass
def main
print 'Run-time names:'
for member in .typeOf.getMembers, print member.name
print
print 'Cobra compile-time names:'
for name in .typeOf.cobraMemberNames, print name
extend Type
def cobraMemberNames as List<of String>
""" Returns a newly created list of Cobra member names for this type. """
names = List<of String>()
for member in .getMembers
name = member.name
if name == '.ctor', name = 'init (cue)'
else if name.startsWith('get_'), name = name[4:].lowered + ' (get)'
else if name.startsWith('set_'), name = name[4:].lowered + ' (set)'
else, name = name.lowered
names.add(name)
return names
extend String
def lowered as String
if .length == 0, return this
return this[0].toString.toLower + this[1:]
Regarding a library reference, we don't have a formal one, but we do have the
LibraryTopics wiki page which I just substantially improved. I consider this the "entry point" for learning more about the libraries that are available.
I also encourage people to contribute to and improve the wiki whenever they discover something.
HTH