Targeting C

bearophile bearophileHUGS at lycos.com
Thu Oct 22 00:07:43 PDT 2009


Tim Matthews:

> OOC. I quite like how this one myself personally. http://ooc-lang.org/about

Type of arguments can be stated once:

Vector3f: class {
  x, y, z : Float
  init: func(x, y, z : Float) {
    this x = x // 'this' is called 'self' in some other languages
    this y = y
    this z = z
  }
}


It doesn't need the is() when you test for type equality:

print: func <T> (arg: T) {
  if(T == Int) {
    printf("%d\n", arg as Int) // 'as' allow casting
  } else if(T == String) {
    printf("%s\n", arg as String)
  }
}

Uses a syntax better than the D foreach:

list := ArrayList<Int> new()
for(i in 0..10) list add(i) // oh yeah no needs for brackets
for(i in list) printf("%d\n")

And I have omitted some other handy features.
There's something to learn for D too :-)

Bye,
bearophile



More information about the Digitalmars-d mailing list