Skip to content

Instantly share code, notes, and snippets.

@hsk
Created July 5, 2014 13:59
Show Gist options
  • Save hsk/e2917a7077801410a75c to your computer and use it in GitHub Desktop.
Save hsk/e2917a7077801410a75c to your computer and use it in GitHub Desktop.
printi(i:int):void = printf("%d\n", i)
A:trait {
p():void = printi(1)
}
C <: A = struct(i:int) {
p():void = printi(i)
}
B:trait {
p2():void
}
C <: B = {
p2():void = printi(22)
}
D : struct(i:int)
D <: A,B = {
p():void = printi(11)
p2():void = printi(22)
}
aa(a:*A):void = a.p(a)
main():int = {
printf("* normal\n")
a:A=A()
a.p()
c:C=C(123)
c.p()
printf("* function\n")
aa(&a)
aa(&c)
printf("* loop\n")
as:*A[] = {&a,&c}
for (int i = 0; i < 2; i++) as[i].p()
0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment