Author Topic: Inheritance Branch  (Read 2332 times)

0 Members and 1 Guest are viewing this topic.

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Inheritance Branch
« on: May 05, 2011 »
v1ctor has added inheritance to FB and you can get the branch from this post on the FB forum. You will probably need to have the current official build installed before applying this. Back up your current installation before applying this though just to be safe.

I have been playing around with it, and it seems to work. Some examples are found in the examples\classes folder. Here is what the new syntax looks like from one of the examples:

Code: [Select]
type Foo
declare function DoSomething() as integer
declare function DoIt() as integer
declare function DoItFromBase() as integer

private:
dim unused as byte
end type

function Foo.DoSomething() as integer
return 1
end function

function Foo.DoIt() as integer
return DoSomething()
end function

function Foo.DoItFromBase() as integer
return DoSomething()
end function

type SuperFoo extends Foo
declare function DoSomething() as integer
declare function DoIt() as integer
end type

function SuperFoo.DoSomething() as integer
return 2
end function

function SuperFoo.DoIt() as integer
return DoSomething()
end function

sub main
dim as SuperFoo inst

assert( inst.DoIt() = 2 )
assert( cast( Foo, inst ).DoIt() = 1 )
assert( inst.DoItFromBase() = 1 )

print "all tests ok"
end sub

main

Notice the extends keyword here. In the above example, SuperFoo inherits from Foo.

I'll be beating on this some and post my findings.