Skip to content

Instantly share code, notes, and snippets.

@od0x0
Created August 31, 2010 22:58
Show Gist options
  • Save od0x0/559931 to your computer and use it in GitHub Desktop.
Save od0x0/559931 to your computer and use it in GitHub Desktop.
Vec3: class{
x, y, z: Float
allocWith: static func(allocator: Func(SizeT)->Pointer) -> This{
object := allocator(Vec3 as Class instanceSize) as This
if(object) object class = This
return object
}
init: func(=x,=y,=z) -> This { this }
print: func -> This { "Vec3(x: %f, y: %f, z: %f)" format(x,y,z) println(); this }
}
malloc: extern func(SizeT) -> Pointer
free(Vec3 allocWith(malloc) init(1.0,2.0,3.0) print())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment